Skip to content

Instantly share code, notes, and snippets.

@wharley
Created October 17, 2016 18:11
Show Gist options
  • Save wharley/6bb898784dcf3a24c30d66988acd0336 to your computer and use it in GitHub Desktop.
Save wharley/6bb898784dcf3a24c30d66988acd0336 to your computer and use it in GitHub Desktop.
getPokmonApi('http://pokeapi.co/api/v2/')
.then(function(body){
console.log(body)
})
function getPokmonApi(url) {
return new Promise(function(resolve, reject){
request(url, function (err, response, body){
if(err && response.statusCode != 200)
return reject(err)
resolve(JSON.parse(body))
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment