Skip to content

Commit 729e800

Browse files
committed
fix typing around headers
1 parent 198f6cf commit 729e800

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

packages/axios-asap/src/index.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
createAuthHeaderGenerator,
33
AuthHeaderConfig,
44
} from '@ordermentum/asap-core';
5-
import axios, { AxiosInstance, AxiosRequestConfig } from 'axios';
5+
import axios, { AxiosInstance, AxiosRequestConfig, AxiosHeaders } from 'axios';
66
import http from 'http';
77
import https from 'https';
88

@@ -12,9 +12,13 @@ export const createAsapInterceptor = (authConfig: AuthHeaderConfig) => {
1212
});
1313
return (config: AxiosRequestConfig) => {
1414
const header = headerGenerator();
15-
const headers = config.headers ?? {};
16-
headers.Authorization = header;
17-
return { ...config, headers };
15+
// @ts-expect-error RawAxiosHeaders is not accessible for type defs
16+
const headers: AxiosHeaders = new AxiosHeaders(config.headers ?? {});
17+
headers.set('Authorization', header);
18+
return {
19+
...config,
20+
headers,
21+
};
1822
};
1923
};
2024

0 commit comments

Comments
 (0)