From a2f2996ef9fc84f852f656fb40f5048a6a324bfa Mon Sep 17 00:00:00 2001 From: Mathis Date: Thu, 20 Jun 2024 14:55:23 +0200 Subject: [PATCH] feat(apiRequest): use JSON.parse for accessToken in Authorization header The Authorization header in the apiRequest now utilizes JSON.parse for the accessToken. This change ensures proper parsing and retrieval of the item from the local storage when the window object is defined. --- src/services/apiRequest.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/apiRequest.ts b/src/services/apiRequest.ts index 441d9b6..c4a4699 100644 --- a/src/services/apiRequest.ts +++ b/src/services/apiRequest.ts @@ -10,7 +10,7 @@ const AxiosConfigs = { return { headers: { "content-type": "application/json", - Authorization: `Bearer ${typeof window !== "undefined" ? window.localStorage.getItem("sub") : "not-ssr"}`, + Authorization: `Bearer ${typeof window !== "undefined" ? JSON.parse(window.localStorage.getItem("sub") || "not-ssr") : "not-ssr"}`, }, validateStatus: (status: number) => { return status < 500; // Resolve only if the status code is less than 500