A generic interface for a fetcher function that can be used to make HTTP requests.
const fetcher: GenericFetcher<{ headers: Record<string, string> }> = { fetch: async (url, method, body, options) => { const response = await fetch(url, { method, body, headers: options?.headers }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } return response.json(); },}; Copy
const fetcher: GenericFetcher<{ headers: Record<string, string> }> = { fetch: async (url, method, body, options) => { const response = await fetch(url, { method, body, headers: options?.headers }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } return response.json(); },};
A generic interface for a fetcher function that can be used to make HTTP requests.
Example