ew/webui/src/Request.jsx
Ethan O'Brien a05e7a8478 Add webui
2024-04-24 19:05:20 -05:00

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;