Created
December 5, 2013 07:03
-
-
Save jchris/7801297 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var requestLib = require("request"), | |
request = requestLib.defaults({ | |
json:true | |
}, function(uri, options, callback){ | |
var params = requestLib.initParams(uri, options, callback); | |
return requestLib(params.uri, params.options, function(err, res, body){ | |
// treat bad status codes as errors | |
if (!err && res.statusCode >= 400) { | |
params.callback.apply(this, [res.statusCode, res, body]); | |
} else { | |
params.callback.apply(this, arguments); | |
} | |
}) | |
}); | |
// note: waiting on https://github.com/mikeal/request/pull/727 for this to work with PUT and POST |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
note: waiting on request/request#727 for this to work with PUT and POST