Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save reganstarr/bbb0e2a782b4fc22820e to your computer and use it in GitHub Desktop.
Save reganstarr/bbb0e2a782b4fc22820e to your computer and use it in GitHub Desktop.
var username = '';
var password = '';
var encoded_credentials = new Buffer(username + ':' + password).toString('base64');
fetch('https://example.com', { method: 'POST', headers: {'Authorization': 'Basic ' + encoded_credentials} })
.then(function(res) {
return res.json();
})
.then(function(body) {
var output = {content: body};
callback(null, output);
})
.catch(callback);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment