Skip to content

AxiosError has status defined as string but it is really number #4684

@pixe1master

Description

@pixe1master

Describe the bug

Type definition for AxiosError is incorrect. The definition was introduced in this commit:
https://github.com/axios/axios/pull/3645/files#diff-7aa4473ede4abd9ec099e87fec67fd57afafaf39e05d493ab4533acc38547eb8R137

When you look at the actual runtime payload it has a number type. For example, a 401 error has status of 401 not "401" when you JSON.stringify(error).

To Reproduce

A code snippet really doesn't make sense here, but you can see the JSON object that was constructed from the error object in the case that I observed.

{
  "message": "Request failed with status code 401",
  "name": "AxiosError",
  "config": {
    "transitional": {
      "silentJSONParsing": true,
      "forcedJSONParsing": true,
      "clarifyTimeoutError": false
    },
    "transformRequest": [null],
    "transformResponse": [null],
    "timeout": 0,
    "xsrfCookieName": "XSRF-TOKEN",
    "xsrfHeaderName": "X-XSRF-TOKEN",
    "maxContentLength": -1,
    "maxBodyLength": -1,
    "env": {},
    "headers": {
      "Accept": "application/json",
      "Cache-Control": "no-cache",
      "Content-Type": "no-cache",
      "User-Agent": "axios/0.27.2"
    },
    "method": "get",
    "url": "https://somedomainrequiringauth.com/some-endpoint-requiring-auth"
  },
  "code": "ERR_BAD_REQUEST",
  "status": 401
}

Expected behavior

The definition should be a number.

Environment

  • Axios Version 0.27.2
  • Adapter HTTP
  • Browser N/A
  • Browser Version N/A
  • Node.js Version v16.14.2
  • OS: OSX 12.2.1
  • Additional Library Versions N/A

Additional context/Screenshots

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions