aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/utils.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2022-12-23 13:51:52 -0800
committerAdam Soltys <[email protected]>2022-12-23 13:51:52 -0800
commit588b8ca814f3c86c5880f075ba0fb58faada873f (patch)
treefec923b0d2787fffe53e1eb92cdb456c47b767e7 /src/lib/utils.js
parent599ae2f6aad7456612f2d7d3fa3c79b7b60ea9c2 (diff)
downloadcoinos-ui-588b8ca814f3c86c5880f075ba0fb58faada873f.tar.gz
coinos-ui-588b8ca814f3c86c5880f075ba0fb58faada873f.zip
require pin on key gen
Diffstat (limited to 'src/lib/utils.js')
-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 {