From 588b8ca814f3c86c5880f075ba0fb58faada873f Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 23 Dec 2022 13:51:52 -0800 Subject: require pin on key gen --- src/lib/utils.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/lib/utils.js') 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 { -- cgit v1.2.3