let username = 'john';
let password = 'doe';
let url = `https://httpbin.org/basic-auth/${username}/${password}`
let authString = `${username}:${password}`
let headers = new Headers();
headers.set('Authorization', 'Basic ' + btoa(authString))
fetch(url,{method: 'GET', headers: headers})
.then(function (response) {
console.log (response)
return response
});
Created
August 1, 2018 14:45
-
-
Save ivermac/922def70ed9eaf83799b68ab1a587595 to your computer and use it in GitHub Desktop.
Using fetch with basic auth
"btoa is not defined" when this code gets used in a Node14 lambda on AWS.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@Eccenux, Thanks, you helped me a lot!