Forked from reganstarr/zapier_code_use_basic_authentication_with_fetch.js
Created
February 19, 2017 21:53
-
-
Save mrjcleaver/c377ab69eacc2eb6549e1fa8aafd1ec3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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