@djust-b2b/djust-front-sdk 1.20.2 → 1.20.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.
|
@@ -78,7 +78,8 @@ async function getCarts(params) {
|
|
|
78
78
|
path: `/v2/shop/carts`,
|
|
79
79
|
params: {
|
|
80
80
|
currency,
|
|
81
|
-
pageable,
|
|
81
|
+
page: pageable === null || pageable === void 0 ? void 0 : pageable.page,
|
|
82
|
+
size: pageable === null || pageable === void 0 ? void 0 : pageable.size,
|
|
82
83
|
status,
|
|
83
84
|
type,
|
|
84
85
|
},
|
|
@@ -115,7 +115,21 @@ const enhancedFetch = async ({ path, method, params = {}, body, }) => {
|
|
|
115
115
|
const isJsonResponse = (_d = headers
|
|
116
116
|
.get("content-type")) === null || _d === void 0 ? void 0 : _d.includes("application/json");
|
|
117
117
|
// Additional check: ensure the response has content before attempting to parse JSON
|
|
118
|
-
|
|
118
|
+
let responseText = await response.text();
|
|
119
|
+
function isJsonString(str) {
|
|
120
|
+
if (typeof str !== "string")
|
|
121
|
+
return false;
|
|
122
|
+
try {
|
|
123
|
+
const parsed = JSON.parse(str);
|
|
124
|
+
return typeof parsed === "object" && parsed !== null;
|
|
125
|
+
}
|
|
126
|
+
catch (_a) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (!isJsonString(responseText)) {
|
|
131
|
+
responseText = `{"data":"${responseText}"}`;
|
|
132
|
+
}
|
|
119
133
|
const data = isJsonResponse && responseText
|
|
120
134
|
? JSON.parse(responseText)
|
|
121
135
|
: {};
|