- From: Marcelo Ribeiro <notifications@github.com>
- Date: Fri, 29 Jul 2022 19:44:17 -0700
- To: whatwg/fetch <fetch@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Saturday, 30 July 2022 02:44:30 UTC
```
// Typescript
export const fetcher = async <T = any>(
input: RequestInfo,
init?: RequestInit
): Promise => {
const response = await fetch(input, init);
if (!response.ok) throw new Error(response.statusText);
return response.json();
};
// Javscript
export const fetcher = async(input, init = {}) => {
const response = await fetch(input, init);
if (!response.ok) throw new Error(response.statusText);
return response.json();
};
```
--
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/18#issuecomment-1200072028
You are receiving this because you are subscribed to this thread.
Message ID: <whatwg/fetch/issues/18/1200072028@github.com>
Received on Saturday, 30 July 2022 02:44:30 UTC