Skip to content

Property 'Authorization' does not exists on type 'AxiosHeaders' after upgrade to 1.2.2 #5416

@andreylh

Description

@andreylh

Summary

I'm getting the following error after upgrading axios to version 1.2.2:

TS2339: Property 'Authorization' does not exist on type 'AxiosHeaders | Partial<RawAxiosHeaders & MethodsHeaders & CommonHeaders>'.
Property 'Authorization' does not exist on type 'AxiosHeaders'

The same snippet of code is working on version 1.2.1:

import axios from 'axios';

axios.interceptors.request.use((request) => {
    request.headers
        ? (request.headers.Authorization = `Bearer ${token}`)
        : (request.headers = { Authorization: `Bearer ${token}` });
});

Environment

  • Axios 1.2.2
  • Node.js 18.12.1
  • OS: Ubuntu 20.04.4 LTS (WSL2)

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