File size: 485 Bytes
dbc8392
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const apiBase = '';

function apiPost(path, body) {
    return fetch(`${apiBase}${path}`, {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify(body)
    }).then(res => res.json());
}

function apiGet(path) {
    return fetch(`${apiBase}${path}`)
        .then(res => res.json());
}

function showResult(id, data) {
    document.getElementById(id).innerText = data.message || JSON.stringify(data, null, 2);
}