@objectstack/client 6.7.1 → 6.8.1
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.
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
package/dist/index.mjs
CHANGED
|
@@ -1410,7 +1410,14 @@ var ObjectStackClient = class {
|
|
|
1410
1410
|
headers: { Origin: this.baseUrl },
|
|
1411
1411
|
body: JSON.stringify(request)
|
|
1412
1412
|
});
|
|
1413
|
-
const raw = await res.json();
|
|
1413
|
+
const raw = await res.json().catch(() => ({}));
|
|
1414
|
+
if (!res.ok) {
|
|
1415
|
+
const message = raw?.message || raw?.error?.message || `Login failed (HTTP ${res.status})`;
|
|
1416
|
+
const err = new Error(message);
|
|
1417
|
+
if (raw?.code) err.code = raw.code;
|
|
1418
|
+
err.status = res.status;
|
|
1419
|
+
throw err;
|
|
1420
|
+
}
|
|
1414
1421
|
const data = raw && (raw.data ?? (raw.token || raw.user ? { token: raw.token, user: raw.user } : void 0));
|
|
1415
1422
|
const normalized = data ? { ...raw, data } : raw;
|
|
1416
1423
|
if (normalized.data?.token) {
|