(path: string, body?: any)
| 16 | } |
| 17 | |
| 18 | export async function apiPost<T>(path: string, body?: any): Promise<T> { |
| 19 | const res = await fetch(`${BASE_URL}${path}`, { |
| 20 | method: "POST", |
| 21 | headers: { "Content-Type": "application/json", ...authHeaders() }, |
| 22 | body: body ? JSON.stringify(body) : undefined, |
| 23 | }); |
| 24 | if (!res.ok) throw new Error(await res.text()); |
| 25 | return res.json(); |
| 26 | } |
| 27 | |
| 28 | export async function apiDelete(path: string): Promise<void> { |
| 29 | const res = await fetch(`${BASE_URL}${path}`, { |
no test coverage detected