diff options
| author | Adam Soltys <[email protected]> | 2022-11-05 11:53:08 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-11-05 11:53:27 -0700 |
| commit | d76060a5dc4f9f3da6d9cea517dff48995fd5818 (patch) | |
| tree | dbeef979157bdbb104526ab16e925176871df1b2 /src/lib/utils.js | |
| parent | 2a2b3d7074e8a784e5673699af2143fdcb01e728 (diff) | |
| download | coinos-ui-invoice-requests.tar.gz coinos-ui-invoice-requests.zip | |
handle lnurl pay requestsinvoice-requests
Diffstat (limited to 'src/lib/utils.js')
| -rw-r--r-- | src/lib/utils.js | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/lib/utils.js b/src/lib/utils.js index 2e0036e1..7e0b8e4f 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -22,12 +22,15 @@ export const g = (url, fetch, headers) => export const get = (url, headers = {}) => fetch(base + url, { headers }) - .then((r) => r.text()) + .then(async (r) => { + if (r.ok) return r.text(); + throw new Error(await r.text()); + }) .then((body) => { try { return JSON.parse(body); } catch (e) { - throw new Error(body); + return body; } }); |
