fetch-check-http-status

A simple response handler which rejects fetch requests on any non-2xx response.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
fetch-check-http-status
102.0.07 years ago7 years agoMinified + gzip package size for fetch-check-http-status in KB

Readme

fetch-check-http-status npm npm
A simple response handler which rejects fetch requests on any non-2xx response.

see: https://github.com/github/fetch#handling-http-error-statuses

Install

npm install --save fetch-check-http-status

Usage

// ES6
import checkStatus from 'fetch-check-http-status';
// or ES5
var checkStatus = require('fetch-check-http-status').default;

fetch('/data')
  .then(checkStatus)
  .then(function(data) {
    console.log('success!', data);
  })
  .catch(function(err) {
    console.log('error!', err);
  });

License

MIT © Griffin Yourick