@djust-b2b/djust-front-sdk 1.20.3 → 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.
@@ -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
- const responseText = await response.text();
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
  : {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djust-b2b/djust-front-sdk",
3
- "version": "1.20.3",
3
+ "version": "1.20.4",
4
4
  "description": "DJUST Front SDK is a versatile JavaScript Software Development Kit (SDK) ",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",