@djust-b2b/djust-front-sdk 1.7.3 → 1.7.4
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.
|
@@ -52,7 +52,7 @@ const serializeParams = (params, useRepeat) => {
|
|
|
52
52
|
return qs.stringify(params, { arrayFormat: "bracket", skipNull: true });
|
|
53
53
|
};
|
|
54
54
|
const enhancedFetch = async ({ path, method, params, body, }) => {
|
|
55
|
-
var _a;
|
|
55
|
+
var _a, _b, _c;
|
|
56
56
|
if (!isClientInitialized(clientConfig)) {
|
|
57
57
|
throw new Error('[Djust SDK] SDK not initialized. Provide both client ID and API key via the "initialize" method.');
|
|
58
58
|
}
|
|
@@ -103,6 +103,12 @@ const enhancedFetch = async ({ path, method, params, body, }) => {
|
|
|
103
103
|
const data = isJsonResponse && responseText
|
|
104
104
|
? JSON.parse(responseText)
|
|
105
105
|
: {};
|
|
106
|
+
// Check if response data contains new accessToken and update configuration
|
|
107
|
+
if (data && ((_b = data === null || data === void 0 ? void 0 : data.token) === null || _b === void 0 ? void 0 : _b.accessToken)) {
|
|
108
|
+
(0, exports.updateConfiguration)({
|
|
109
|
+
accessToken: (_c = data === null || data === void 0 ? void 0 : data.token) === null || _c === void 0 ? void 0 : _c.accessToken,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
106
112
|
return { data, headers, status };
|
|
107
113
|
}
|
|
108
114
|
catch (error) {
|