Skip to content

Instantly share code, notes, and snippets.

@markwithers
Created February 20, 2018 16:02
Show Gist options
  • Save markwithers/31f8a43df6db7c1656441fec0fec1285 to your computer and use it in GitHub Desktop.
Save markwithers/31f8a43df6db7c1656441fec0fec1285 to your computer and use it in GitHub Desktop.
const Future = require('fluture')
const got = require('got')
const futureFetch = (url, options) => {
return new Future((reject, resolve) => {
got(url, options).then(resolve).catch(reject)
})
}
futureFetch(
{ protocol: 'http:', port: 8080, path: '/api', host: 'localhost' },
{ json: true }
).fork(console.error, res => console.log(res.body.message))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment