mirror of
https://git.ethanthesleepy.one/ethanaobrien/ew.git
synced 2025-05-13 11:37:33 -05:00
18 lines
409 B
JavaScript
18 lines
409 B
JavaScript
|
|
const serverUrl = "";
|
|
|
|
async function api(url, body) {
|
|
try {
|
|
let options = body ? {method: "POST", body: JSON.stringify(body)} : {}
|
|
const resp = await fetch(serverUrl + url, options);
|
|
const text = await resp.text();
|
|
return JSON.parse(text);
|
|
} catch(e) {
|
|
return {
|
|
result: "ERR",
|
|
message: e.message
|
|
}
|
|
}
|
|
}
|
|
|
|
export default api;
|