Popsicle Status
Reject responses on HTTP failure status codes (404, 500, etc).
Installation
npm install popsicle-status --save
Usage
var request = require('popsicle')
var status = require('popsicle-status')
request('/users.json')
.use(status())
.catch(function (error) {
console.log(error.type)
console.log(error.message)
console.log(error.status)
console.log(error.popsicle)
})
- status() Use default status codes (min:
200
, max: 399
) - status(number) Set the only valid HTTP status code
- status(number, number) Set both the minimum and maximum HTTP status codes
TypeScript
Includes a type definition for TypeScript.
License
MIT