diff options
Diffstat (limited to 'src/js/arching-kaos-fetch.js')
-rw-r--r-- | src/js/arching-kaos-fetch.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/js/arching-kaos-fetch.js b/src/js/arching-kaos-fetch.js new file mode 100644 index 0000000..91e2419 --- /dev/null +++ b/src/js/arching-kaos-fetch.js @@ -0,0 +1,33 @@ +function archingKaosFetchJSON( url, callback ){ + fetch(url, { + method:'GET', + headers:{ + Accept: 'application/json' + } + }).then(response=>{ + if(response.ok){ + response.json().then(json=>{ + callback(json); + }) + } else { + if (DEBUG) console.log(e); + } + }) +} + +async function archingKaosFetchText( url, callback ){ + return fetch(url, { + method:'GET', + headers:{ + Accept: 'application/json' + } + }).then(response=>{ + if(response.ok){ + response.text().then(text=>{ + return callback(text); + }) + } else { + if (DEBUG) console.log(e); + } + }) +} |