aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/utils.js')
-rw-r--r--src/lib/utils.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lib/utils.js b/src/lib/utils.js
index 25b331ed..d7fba2fc 100644
--- a/src/lib/utils.js
+++ b/src/lib/utils.js
@@ -46,11 +46,12 @@ export const post = (url, body, headers) => {
if (r.ok) return r.text();
let text = await r.text();
+ let message;
try {
- let { message } = JSON.parse(text);
- if (message) throw new Error(message);
+ ({ message } = JSON.parse(text));
} catch (e) {}
+ if (message) throw new Error(message);
throw new Error(text);
})
.then((body) => {