( path: string, signal?: AbortSignal )
| 39 | // TODO: Might want to handle flash messages as close to the request as possible |
| 40 | // to make use of the Response object (message, status, etc) |
| 41 | async function get<T>( |
| 42 | path: string, |
| 43 | signal?: AbortSignal |
| 44 | ): Promise<ResponseWithData<T>> { |
| 45 | const response = await fetch(`${base}${path}`, { |
| 46 | ...defaultOptions, |
| 47 | headers: { 'CSRF-Token': getCSRFToken() }, |
| 48 | signal |
| 49 | }); |
| 50 | |
| 51 | return combineDataWithResponse(response); |
| 52 | } |
| 53 | |
| 54 | async function combineDataWithResponse<T>(response: Response) { |
| 55 | const data = (await response.json()) as T; |
no test coverage detected