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 | c3582a86bd2817bb6cbf02840bb8da00d02ab4ff (patch) | |
| tree | dbeef979157bdbb104526ab16e925176871df1b2 /src/lib/utils.js | |
| parent | 20c404fbccea44a1af06f06c36b75cf6f412e0e1 (diff) | |
| download | coinos-ui-c3582a86bd2817bb6cbf02840bb8da00d02ab4ff.tar.gz coinos-ui-c3582a86bd2817bb6cbf02840bb8da00d02ab4ff.zip | |
handle lnurl pay 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; } }); |
