Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with superagent-bluebird-promise #30

Open
zachlysobey opened this issue May 1, 2016 · 0 comments
Open

Compatibility with superagent-bluebird-promise #30

zachlysobey opened this issue May 1, 2016 · 0 comments

Comments

@zachlysobey
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant