1.0.0 • Published 8 years ago

sane-fetch v1.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

sane-fetch

Build status Git tag NPM version Code style

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 fetch
  • params - 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 object
  • body - The deserialized response body. This may be an object, string, or buffer, depending on the type of response.

License

MIT