Skip to content

Instantly share code, notes, and snippets.

@wilmoore
Created January 21, 2016 16:11
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 wilmoore/4db1e05be6896b393e5a to your computer and use it in GitHub Desktop.
Save wilmoore/4db1e05be6896b393e5a to your computer and use it in GitHub Desktop.
Pokemon API Exploration
'use strict'
const all = require('promise-all')
const got = require('got')
const map = require('arraymap')
const mapcat = require('array-mapcat')
const pipe = require('function-pipeline')
const selectn = require('selectn')
const unique = require('array-unique')
function request (path) {
return got(`http://pokeapi.co${path}`, {
json: true, timeout: 500
})
}
request('/api/v1/type/9')
.then(selectn('body.super_effective'))
.then(map('resource_uri'))
.then(map(request))
.then(all)
.then(mapcat('body.weakness'))
.then(map('name'))
.then(unique)
.catch(pipe(selectn('response.body'), console.error))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment