Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flaccid/8c17df55b5477610ebe25d273d651c90 to your computer and use it in GitHub Desktop.
Save flaccid/8c17df55b5477610ebe25d273d651c90 to your computer and use it in GitHub Desktop.
learning async promises
var rsApiClient = function (){
var self = this;
self.login = function (host, refreshToken){
var fetch = require('node-fetch');
var FormData = require('form-data');
var form = new FormData();
form.append('refresh_token', refreshToken);
form.append('grant_type', 'refresh_token');
var result = fetch('https://'+host+'/api/oauth2', {
headers: { 'X-API-Version': '1.5' },
method: 'POST',
body: form
}).then(function(res) {
return res.text()
})
return result
};
};
module.exports = rsApiClient;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment