@djust-b2b/djust-front-sdk 1.7.2 → 1.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -62,6 +62,12 @@ const enhancedFetch = async ({ path, method, params, body, }) => {
|
|
|
62
62
|
"dj-api-key": apiKey,
|
|
63
63
|
"Content-Type": "application/json",
|
|
64
64
|
});
|
|
65
|
+
if ((0, utils_1.isBrowser)()) {
|
|
66
|
+
const token = (0, utils_1.getCookie)("token");
|
|
67
|
+
if (token) {
|
|
68
|
+
requestHeaders.append("Authorization", `Bearer ${token}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
65
71
|
if (accessToken)
|
|
66
72
|
requestHeaders.append("Authorization", `Bearer ${accessToken}`);
|
|
67
73
|
if (locale)
|
|
@@ -90,12 +96,6 @@ const enhancedFetch = async ({ path, method, params, body, }) => {
|
|
|
90
96
|
const errorMessage = await response.text();
|
|
91
97
|
throw new Error(`[Djust SDK] HTTP error ${status}: ${errorMessage}`);
|
|
92
98
|
}
|
|
93
|
-
if ((0, utils_1.isBrowser)()) {
|
|
94
|
-
const token = (0, utils_1.getCookie)("token");
|
|
95
|
-
if (token) {
|
|
96
|
-
requestHeaders.append("Authorization", `Bearer ${token}`);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
99
|
const isJsonResponse = (_a = headers
|
|
100
100
|
.get("content-type")) === null || _a === void 0 ? void 0 : _a.includes("application/json");
|
|
101
101
|
// Additional check: ensure the response has content before attempting to parse JSON
|