Skip to content

Commit 5a8bd80

Browse files
committed
fix:refactor headers logic
Signed-off-by: Amitkanswal <[email protected]>
1 parent 6e1cbf4 commit 5a8bd80

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/utils/utils.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,6 @@ export const fetchToAxiosConfig = (
8989
export function axiosToFetchResponse(axiosRes: AxiosResponse): Response {
9090
const { data, status, statusText, config } = axiosRes;
9191

92-
const headersObj = Object.fromEntries(
93-
Object.entries(config.headers).map(([key, value]) => [key, String(value)])
94-
);
95-
9692
let body: BodyInit;
9793
let contentType = "application/json";
9894

@@ -107,14 +103,14 @@ export function axiosToFetchResponse(axiosRes: AxiosResponse): Response {
107103
body = JSON.stringify(data);
108104
}
109105

110-
if (!headersObj["content-type"]) {
111-
headersObj["content-type"] = contentType;
106+
if (!config.headers["content-type"]) {
107+
config.headers["content-type"] = contentType;
112108
}
113109

114110
const responseInit: ResponseInit = {
115111
status,
116112
statusText,
117-
headers: new Headers(headersObj),
113+
headers: config.headers,
118114
};
119115

120116
return new Response(body, responseInit);

0 commit comments

Comments
 (0)