2.0.0 • Published 8 years ago

fetch-check-http-status v2.0.0

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

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