aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/utils.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2022-10-17 23:29:32 -0700
committerAdam Soltys <[email protected]>2022-10-17 23:29:32 -0700
commit119e88ad2b7782a009c5cb153ca18dab39d22942 (patch)
tree03fe0719e4c623cf6d6b649c0867b910b6db5199 /src/lib/utils.js
parent5313f226c7f946e91d898e6987353f8c1c903204 (diff)
downloadcoinos-ui-119e88ad2b7782a009c5cb153ca18dab39d22942.tar.gz
coinos-ui-119e88ad2b7782a009c5cb153ca18dab39d22942.zip
invoice redirect
Diffstat (limited to 'src/lib/utils.js')
-rw-r--r--src/lib/utils.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/lib/utils.js b/src/lib/utils.js
index 54e965d9..76ce5077 100644
--- a/src/lib/utils.js
+++ b/src/lib/utils.js
@@ -9,6 +9,17 @@ export function scroll(section) {
const base = browser ? '' : env.PUBLIC_COINOS_URL;
+export const g = (url, fetch, headers) =>
+ fetch(base + url, { headers })
+ .then((r) => r.text())
+ .then((body) => {
+ try {
+ return JSON.parse(body);
+ } catch (e) {
+ throw new Error(body);
+ }
+ });
+
export const get = (url, headers = {}) =>
fetch(base + url, { headers })
.then((r) => r.text())