- From: Marcelo Ribeiro <notifications@github.com>
- Date: Fri, 29 Jul 2022 19:43:26 -0700
- To: whatwg/fetch <fetch@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Saturday, 30 July 2022 02:43:38 UTC
// Typescript
export const fetcher = async <T = any>(
input: RequestInfo,
init?: RequestInit
): Promise<T> => {
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-1200071905
You are receiving this because you are subscribed to this thread.
Message ID: <whatwg/fetch/issues/18/1200071905@github.com>
Received on Saturday, 30 July 2022 02:43:38 UTC