export const url = "http://localhost:8000"; export async function postToServer(path: string, body: object, asText = false) { const res = await fetch(url + path, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(body), }); if (asText) return await res.text() return res.json(); } export async function fetchFromServer(path: string, asText = false) { const res = await fetch(url + path); if (asText) return await res.text() return res.json(); } export async function deleteOnServer(path: string, asText = false) { const res = await fetch(url + path, { method: "DELETE" }); if (asText) return await res.text() return res.json(); }