Created
May 8, 2016 04:47
-
-
Save flaccid/8c17df55b5477610ebe25d273d651c90 to your computer and use it in GitHub Desktop.
learning async promises
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 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