( method: HttpMethod, input: RequestInfo, req: REQ | null, init?: RequestInit, )
| 65 | } |
| 66 | |
| 67 | async function makeRequest<REQ, RES>( |
| 68 | method: HttpMethod, |
| 69 | input: RequestInfo, |
| 70 | req: REQ | null, |
| 71 | init?: RequestInit, |
| 72 | ): Promise<ResponseWithHeaders<RES>> { |
| 73 | const res = await fetchHelper(method, input, req, init); |
| 74 | |
| 75 | if (!res.ok) { |
| 76 | throw new FetchError( |
| 77 | "An error occurred while fetching the data.", |
| 78 | res.status, |
| 79 | await res.json(), |
| 80 | ); |
| 81 | } |
| 82 | |
| 83 | const parsedResponse = await res.json(); |
| 84 | return { |
| 85 | response: parsedResponse as RES, |
| 86 | headers: parseResponseHeaders(res), |
| 87 | }; |
| 88 | } |
| 89 | |
| 90 | async function makeRequestStreaming<REQ>({ |
| 91 | method, |
no test coverage detected