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
commit02af363d2f0d552a72dc1c90bf8d785e04465d3a (patch)
tree03fe0719e4c623cf6d6b649c0867b910b6db5199 /src/lib/utils.js
parent5e3d4133760962db28c4f3a595f0566bd59391ff (diff)
downloadcoinos-ui-02af363d2f0d552a72dc1c90bf8d785e04465d3a.tar.gz
coinos-ui-02af363d2f0d552a72dc1c90bf8d785e04465d3a.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())