( method: string, url: string, data?: unknown | undefined, )
| 8 | } |
| 9 | |
| 10 | export async function apiRequest( |
| 11 | method: string, |
| 12 | url: string, |
| 13 | data?: unknown | undefined, |
| 14 | ): Promise<Response> { |
| 15 | const res = await fetch(url, { |
| 16 | method, |
| 17 | headers: data ? { "Content-Type": "application/json" } : {}, |
| 18 | body: data ? JSON.stringify(data) : undefined, |
| 19 | credentials: "include", |
| 20 | }); |
| 21 | |
| 22 | await throwIfResNotOk(res); |
| 23 | return res; |
| 24 | } |
| 25 | |
| 26 | type UnauthorizedBehavior = "returnNull" | "throw"; |
| 27 | export const getQueryFn: <T>(options: { |
no test coverage detected