08-15-2019 10:35 - edited 08-16-2019 01:26
08-15-2019 10:35 - edited 08-16-2019 01:26
I would like to use companion fetch to 3rd party REST API with Basic Authorization to get token response, which it need base64 to encode client_id : password, so How can i use like a base64.encode(client_id : password) in companion?
code as bellows:-
fetch (ENDPOINT, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': 'Basic '+base64.encode(client_id+”:”+password) }
)
.then(res=>{
// Do something....
}
.catch(err=>{
// Do something....
});