flare / static /common.js
ciyidogan's picture
Create common.js
d917409 verified
raw
history blame
467 Bytes
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);
}