Skip to content

Instantly share code, notes, and snippets.

@SZharkov
Created January 21, 2020 17:33
Show Gist options
  • Save SZharkov/6fbc979848fd344ffd23ef6b4c4d28f3 to your computer and use it in GitHub Desktop.
Save SZharkov/6fbc979848fd344ffd23ef6b4c4d28f3 to your computer and use it in GitHub Desktop.
Basic authentication with fetch
// Node
headers.set('Authorization', 'Basic ' + Buffer.from(username + ":" + password).toString('base64'));
// Browser
headers.set('Authorization', 'Basic ' + btoa(username + ":" + password));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment