Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Companion to fetch basic authorization with base64 encode

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....
});

 

Best Answer
0 Votes
0 REPLIES 0