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)