Abstract
Optional
opt: {Optional
baseUrl?: stringOptional base URL to be prepended to all request paths.
Optional
debug?: booleanOnly for debugging purposes, if true, will log additional information to the console.
Optional
defaultOptions?: OptionTypeDefault options to be merged with options passed to each fetch call. Useful for setting default headers, credentials, etc.
Optional
fetcher?: GenericFetcher<OptionType>If you need capabilities beyond the options passed to the fetch method, you can provide your own fetcher implementation.
defaultFetcher for the default implementation.
Makes a DELETE request to the specified endpoint.
Optional
options: Partial<Optional
fetchOptions: Partial<OptionType>fetch for the base method.
Base fetch method, allowing to specify any HTTP method.
Optional
fetchOptions: Partial<OptionType>Makes a GET request to the specified endpoint.
Optional
options: Partial<Optional
fetchOptions: Partial<OptionType>fetch for the base method.
Makes a HEAD request to the specified endpoint.
Optional
options: Partial<Optional
fetchOptions: Partial<OptionType>fetch for the base method.
Makes a PATCH request to the specified endpoint.
Optional
options: Partial<Optional
fetchOptions: Partial<OptionType>fetch for the base method.
Makes a POST request to the specified endpoint.
Optional
options: Partial<Optional
fetchOptions: Partial<OptionType>fetch for the base method.
Makes a PUT request to the specified endpoint.
Optional
options: Partial<Optional
fetchOptions: Partial<OptionType>fetch for the base method.
Tries to call a method on the API service and returns a tuple of [error, response].
Generic API service, supporting type safety for endpoints, path params, query params and request/response bodies.
Although it uses fetch in a very simple way beneath the hood, you can BYO fetch implementation by passing it in the constructor.
See
Example