Skip to content

AxiosHeaders class type definitions expose a missing setAuthorization method #5501

Closed

Description

@vovaklimov

Describe the bug

I'm trying to create a basic request interceptor to set Authorization header. According to axios type definitions, I can use config.headers.setAuthorization method in my interceptor.

image

image

TypeScript compiles my source code correctly, but it fails to run, throwing a TypeError

image

To Reproduce

https://runkit.com/embed/70jjrl0otnq7

Code snippet

import axios from 'axios';

axios.interceptors.request.use((config) => {
  config.headers.setAuthorization('Bearer 🐻');

  return config;
});

await axios.get('https://www.google.com')

Expected behavior

I expect config.headers.setAuthorization() to correctly set Authorization http header for HTTP requests in runtime according to type definitions.

Axios Version

1.2.5

Adapter Version

HTTP

Browser

No response

Browser Version

No response

Node.js Version

18.13.0

OS

Fedora 37

Additional Library Versions

"@types/node": "^18.11.18"
"typescript": "^4.9.4"

Additional context/Screenshots

No response

Activity

  1. changed the title [-]AxiosHeaders class type definitions expose missing methods[/-] [+]AxiosHeaders class type definitions expose a missing setAuthorization method[/+] on Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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