@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 CHANGED
@@ -1440,7 +1440,14 @@ var ObjectStackClient = class {
1440
1440
  headers: { Origin: this.baseUrl },
1441
1441
  body: JSON.stringify(request)
1442
1442
  });
1443
- const raw = await res.json();
1443
+ const raw = await res.json().catch(() => ({}));
1444
+ if (!res.ok) {
1445
+ const message = raw?.message || raw?.error?.message || `Login failed (HTTP ${res.status})`;
1446
+ const err = new Error(message);
1447
+ if (raw?.code) err.code = raw.code;
1448
+ err.status = res.status;
1449
+ throw err;
1450
+ }
1444
1451
  const data = raw && (raw.data ?? (raw.token || raw.user ? { token: raw.token, user: raw.user } : void 0));
1445
1452
  const normalized = data ? { ...raw, data } : raw;
1446
1453
  if (normalized.data?.token) {