forwardemail / forwardemail/superagent

401 comes in either error.status or error.statusCode

Open
#1,529 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
16.6k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

I've got two URLs, both returning a HTTP 401.
Depending on which URL I'm accessing, superagent returns the 401 in either the `error.status` or the `error.statusCode` property. According to [the documentation](http://visionmedia.github.io/superagent/#error-handling), it should come in the `status` property.
The code is trivial:

```
'use strict';

const superagent = require ('superagent');

superagent.get ('https://...')
.then (
() => console.log ('ok'),
(error) => console.log ({ status: error.status, statusCode: error.statusCode }),
);
```

What might trigger this bug is that in the case where the HTTP status code comes in the `error.statusCode` property, the HTTP response comes with a `content-type: application/json;charset=utf-8` header but with a body that is invalid JSON.

I used the currently latest version 5.1.0.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.