aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/utils.js7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/lib/utils.js b/src/lib/utils.js
index 2e0036e1..7e0b8e4f 100644
--- a/src/lib/utils.js
+++ b/src/lib/utils.js
@@ -22,12 +22,15 @@ export const g = (url, fetch, headers) =>
export const get = (url, headers = {}) =>
fetch(base + url, { headers })
- .then((r) => r.text())
+ .then(async (r) => {
+ if (r.ok) return r.text();
+ throw new Error(await r.text());
+ })
.then((body) => {
try {
return JSON.parse(body);
} catch (e) {
- throw new Error(body);
+ return body;
}
});