go-fetch-json
v1.1.0
Published
A plugin for `go-fetch` that makes working with JSON easier.
Downloads
43
Readme
go-fetch-json
A plugin for go-fetch
that makes working with JSON easier.
Installation
npm install --save go-fetch-json
Usage
const Client = require('go-fetch');
const json = require('go-fetch-json');
new Client()
.use(json())
.post('http://httpbin.org/post', {msg: 'Go fetch!'}) //send an object as JSON
.then(res => {
console.log('Is JSON?', res.isJSON());
return res.json(); //buffer and parse the body as JSON
})
.then(json => console.log(json))
.catch(err => console.error(err.stack))
;