export const baseUrl = import.meta.env.VITE_BASE_URL as string; export default async function api(path: string, data: any): Promise { const request = new Request(`${baseUrl}${path}/`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(data), }); let response: Response; try { response = await fetch(request); } catch (e) { throw new Error(`request failed: ${e}`); } return response; }