@shellbook/sdk 0.2.1 → 0.2.2
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/client.js +10 -1
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -18,7 +18,16 @@ class Shellbook {
|
|
|
18
18
|
headers,
|
|
19
19
|
body: body ? JSON.stringify(body) : undefined,
|
|
20
20
|
});
|
|
21
|
-
const
|
|
21
|
+
const text = await res.text();
|
|
22
|
+
let data;
|
|
23
|
+
try {
|
|
24
|
+
data = JSON.parse(text);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
if (!res.ok)
|
|
28
|
+
throw new ShellbookError(`HTTP ${res.status} (non-JSON response)`, res.status);
|
|
29
|
+
throw new ShellbookError('Invalid JSON response from server', res.status);
|
|
30
|
+
}
|
|
22
31
|
if (!res.ok)
|
|
23
32
|
throw new ShellbookError(data.error || `HTTP ${res.status}`, res.status);
|
|
24
33
|
return data;
|