aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2022-11-05 11:53:08 -0700
committerAdam Soltys <[email protected]>2022-11-05 11:53:27 -0700
commitd76060a5dc4f9f3da6d9cea517dff48995fd5818 (patch)
treedbeef979157bdbb104526ab16e925176871df1b2 /src/lib
parent2a2b3d7074e8a784e5673699af2143fdcb01e728 (diff)
downloadcoinos-ui-invoice-requests.tar.gz
coinos-ui-invoice-requests.zip
handle lnurl pay requestsinvoice-requests
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/utils.js7
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;
}
});