aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/utils.js
diff options
context:
space:
mode:
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())