Creates a reusable HTTP request function with predefined options.
const fetcher = FetchFactory<RequestType, ResponseType>({ method: 'POST', caller: fetch, headers: { 'Content-Type': 'application/json' }});const response = await fetcher('/api/endpoint', data); Copy
const fetcher = FetchFactory<RequestType, ResponseType>({ method: 'POST', caller: fetch, headers: { 'Content-Type': 'application/json' }});const response = await fetcher('/api/endpoint', data);
The type of data that will be sent in the request
The type of data that will be returned from the request
Configuration options for the fetch factory
A function that makes HTTP requests with the configured options The returned function accepts:
Creates a reusable HTTP request function with predefined options.
Example