aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/utils.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/lib/utils.js b/src/lib/utils.js
index 5ffc24e2..79509cc1 100644
--- a/src/lib/utils.js
+++ b/src/lib/utils.js
@@ -44,7 +44,14 @@ export const post = (url, body, headers) => {
return fetch(base + url, { method: 'POST', body: JSON.stringify(body), headers })
.then(async (r) => {
if (r.ok) return r.text();
- throw new Error(await r.text());
+ let text = await r.text();
+
+ try {
+ let { message } = JSON.parse(text);
+ if (message) return JSON.stringify({ name: 'Error', message });
+ } catch (e) {}
+
+ return text;
})
.then((body) => {
try {