aboutsummaryrefslogtreecommitdiff
path: root/src/js/arching-kaos-fetch.js
blob: 91e241912b8d134a26d381af81892864212e9cef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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);
        }
    })
}