( method: 'POST' | 'PUT' | 'DELETE', path: string, body: unknown )
| 78 | } |
| 79 | |
| 80 | async function request<T>( |
| 81 | method: 'POST' | 'PUT' | 'DELETE', |
| 82 | path: string, |
| 83 | body: unknown |
| 84 | ): Promise<ResponseWithData<T>> { |
| 85 | const options: RequestInit = { |
| 86 | ...defaultOptions, |
| 87 | method, |
| 88 | headers: { |
| 89 | 'CSRF-Token': getCSRFToken(), |
| 90 | 'Content-Type': 'application/json' |
| 91 | }, |
| 92 | body: JSON.stringify(body) |
| 93 | }; |
| 94 | |
| 95 | const response = await fetch(`${base}${path}`, options); |
| 96 | return combineDataWithResponse(response); |
| 97 | } |
| 98 | |
| 99 | /** GET **/ |
| 100 |