kwest-handle-error
v0.1.0
Published
Reject responses with bad statuscode
Downloads
4
Readme
kwest-handle-error
Error handler middleware for kwest module. Rejects responses with bad statuscodes.
Installation
$ npm install --save kwest-handle-error
Use
without errorHandler
var request = require('kwest-base');
request('http://www.example.com/not-found')
.then(function (res) {
console.log(res.statusCode); // 404
});
with errorHandler
var handleError = require('kwest-handle-error'),
kwest = require('kwest-base'),
request = kwest.wrap(handleError());
request('http://www.example.com/not-found')
.catch(function (err) {
console.log(err.message); // "404: Not found"
});