I am trying to encode the API Key in B64 to been able to have a secured communication. Baed on what I have read at different forums, including : How do you encode api key to base64 for freshdesk?
It suggests to use the method: btoa, but it always sayis that that bethod is not defined:
I have a serverless app, so I retrieve the iparams:
//console.log(args);
var subdomain = args['iparams']['fd_domain'];
var subdomain = args['iparams']['api_key'];
var EncodedAuthentication = btoa(apiKey.value);
console.log(EncodedAuthentication);
Step 1. (Only if required)
If you do not have the btoa on your local machine, download it. To do so, you simply need to open your console and set the next command:
npm install btoa
Step 2.
At the manifest, include the dependecy of the btoa:
If you are using any script file and getting "Uncaught ReferenceError: x is not defined " which means ‘x’ is either a variable or a method which you are trying to use before declaring it using var keyword. This means that there is a non-existent variable referenced somewhere. This variable needs to be declared, or you need to make sure it is available in your current script or scope otherwise , it will endup throwing this ‘x’ is not defined error . This usually indicates that your library is not loaded and JavaScript does not recognize the ‘x’.
To solve this error: Load your library at the beginning of all your scripts.
There can be multiple other reasons for this issue: