-
Notifications
You must be signed in to change notification settings - Fork 32
Compatibility with superagent-bluebird-promise #30
Description
I'm using your library in conjunction with superagent-bluebird-promise, but it seems not to work for non-200 responses.
The following superagent-bluebird-promise code ends up causing an error:
Uncaught TypeError: Cannot read property 'status' of null
if (typeof res !== "undefined" && res.status >= 400) {
var msg = 'cannot ' + req.method + ' ' + req.url + ' (' + res.status + ')'From: https://github.com/KyleAMathews/superagent-bluebird-promise/blob/master/index.js#L66-L67
This is happening when superagent-mocker calls that function with res passed in as null rather than undefined.
if (response.status !== 200) {
cb && cb(response, null);From: https://github.com/A/superagent-mocker/blob/master/index.js#L99-L100
I'm not entirely sure which of your libraries is responsible for this bug, but either case looks like a pretty easy fix. (I've submitted an issue to superagent-mocker as well: KyleAMathews/superagent-bluebird-promise#53)
If you want, I can submit a PR to change
cb && cb(response, null);to
cb && cb(response, undefined);or
cb && cb(response);Either change could be a quick fix for my issue.
Thanks for taking your time to contribute this very useful library to the OSS community!