@@ -2,7 +2,7 @@ import respond from "../utils/respond";
22import { RequestOptions } from "../utils/authorization" ;
33import { ImageKitOptions } from "../libs/interfaces/" ;
44import { IKCallback } from "../libs/interfaces/IKCallback" ;
5- import axios , { AxiosError , AxiosRequestConfig , AxiosResponse } from "axios" ;
5+ import axios , { AxiosError , AxiosHeaders , AxiosRequestConfig , AxiosResponse } from "axios" ;
66
77export 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