sane-fetch
v1.0.0
Published
A sane fetch wrapper.
Downloads
4
Readme
sane-fetch
A sane fetch wrapper - deserialized body and better error handling.
Installation
$ npm install sane-fetch
Usage
import fetch from 'sane-fetch'
fetch('https://www.google.com').then((res) => res)
// =>
// {
// url: https://www.google.com,
// status: 200,
// statusText: 'OK',
// headers: ...,
// body: ...
// }
API
fetch(url, params)
url
- url to fetchparams
- parameters of fetch
Returns: promise that resolves response
response
url
- The url of the endpoint you requested (as returned by the request)status
- The numerical status code of the response (e.g. 200)statusText
- The text version of the status (e.g. 'OK')headers
- A Headers objectbody
- The deserialized response body. This may be an object, string, or buffer, depending on the type of response.
License
MIT