(method: string, path: string, body?: any)
| 34 | }; |
| 35 | |
| 36 | async function _fetch(method: string, path: string, body?: any): Promise<[number, Response]> { |
| 37 | const response = await window.fetch(`/api${path}`, { |
| 38 | ...(method === "GET" ? commonHeaders : mutatingHeaders), |
| 39 | method, |
| 40 | body: body ? JSON.stringify(body) : undefined, |
| 41 | }); |
| 42 | |
| 43 | return [response.status, response]; |
| 44 | } |
| 45 | |
| 46 | async function get<T>(path: string, params?: Record<string, any>): Promise<T> { |
| 47 | const paramsStr = params ? new URLSearchParams(params).toString() : ""; |