diff options
| author | Adam Soltys <[email protected]> | 2022-12-23 13:51:52 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-12-23 13:51:52 -0800 |
| commit | 6ad80880626e84b879b86dab5ac8f0bbfc383c8f (patch) | |
| tree | fec923b0d2787fffe53e1eb92cdb456c47b767e7 /src/lib/utils.js | |
| parent | 510e956d9e9d0adf9b1900fe56545119912a08c4 (diff) | |
| download | coinos-ui-6ad80880626e84b879b86dab5ac8f0bbfc383c8f.tar.gz coinos-ui-6ad80880626e84b879b86dab5ac8f0bbfc383c8f.zip | |
require pin on key gen
Diffstat (limited to 'src/lib/utils.js')
| -rw-r--r-- | src/lib/utils.js | 9 |
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 { |
