Hi Thierno,
Welcome to the wonderful world where Codeless meets code. Here’s what you can do to add this functionality:
- Click
Business Logic
In theBACKEND
section of console and switch to theCODING
tab. - Make sure
JS
is selected in the drop down, right click theservices
node in the tree:
- Select
New File
and enterBase64Service.js
. ClickCREATE
- Paste the following code in the editor:
class Base64Service
{
/**
* @param {String} data
* @returns {Promise.<String>}
*/
toBase64( data ) {
return Buffer.from( data ).toString('base64')
}
/**
* @param {String} data
* @returns {Promise.<String>}
*/
fromBase64( data ) {
return Buffer.from( data, 'base64' ).toString()
}
}
Backendless.ServerCode.addService( Base64Service );
- Click the button to deploy the service:
- Once deployed, switch to the
API SERVICES
tab and try it out by entering some text into thedata
field and clickingINVOKE
:
- Now that the service is there and is working, you can start using it in Codeless:
Hope this helps.
Mark