robert2206 8ad867f7a5 commit inicial | 8 年之前 | |
---|---|---|
.. | ||
LICENSE | 8 年之前 | |
README.md | 8 年之前 | |
package.json | 8 年之前 | |
popsicle-status.d.ts | 8 年之前 | |
popsicle-status.js | 8 年之前 |
Reject responses on HTTP failure status codes (404, 500, etc).
npm install popsicle-status --save
var request = require('popsicle')
var status = require('popsicle-status')
request('/users.json')
.use(status())
.catch(function (error) {
console.log(error.type) //=> "EINVALIDSTATUS"
console.log(error.message) //=> "Invalid HTTP status, 404, should be between 200 and 399"
console.log(error.status) //=> 404
console.log(error.popsicle) //=> Popsicle#Request
})
200
, max: 399
)Includes a type definition for TypeScript.
MIT