Skip to content

Commit 4d5bb92

Browse files
ANKUR DWIVEDIANKUR DWIVEDI
authored andcommitted
parse AxiosHeader
1 parent 4f59ece commit 4d5bb92

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

utils/request.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import respond from "../utils/respond";
22
import { RequestOptions } from "../utils/authorization";
33
import { ImageKitOptions } from "../libs/interfaces/";
44
import { IKCallback } from "../libs/interfaces/IKCallback";
5-
import axios, { AxiosError, AxiosRequestConfig, AxiosResponse } from "axios";
5+
import axios, { AxiosError, AxiosHeaders, AxiosRequestConfig, AxiosResponse } from "axios";
66

77
export default function request<T, E extends Error>(
88
requestOptions: RequestOptions,
@@ -31,7 +31,7 @@ export default function request<T, E extends Error>(
3131
const { data, status, headers } = response;
3232
const responseMetadata = {
3333
statusCode: status,
34-
headers: Object.assign({}, headers)
34+
headers: headers instanceof AxiosHeaders ? headers.toJSON() : headers
3535
}
3636
var result = data ? data : {} as T;
3737
// define status code and headers as non-enumerable properties on data
@@ -48,7 +48,7 @@ export default function request<T, E extends Error>(
4848
// that falls out of the range of 2xx
4949
const responseMetadata = {
5050
statusCode: error.response.status,
51-
headers: Object.assign({}, error.response.headers)
51+
headers: error.response.headers instanceof AxiosHeaders ? error.response.headers.toJSON() : error.response.headers
5252
}
5353

5454
var result = {} as Object;

0 commit comments

Comments
 (0)