Function: useFetch()
useFetch<
E,Params,R>(params,fetchStrategy,options,path):object
Defined in: packages/core/src/react/hooks/useFetch.ts:30
The use Fetch Hook is the foundation for most hooks in the headless framework. It is a wrapper around
useSWR and provides a consistent API for fetching data from the API. It requires a fetch strategy which implements
the actual data fetching logic
Type Parameters
E
E
Params
Params extends EndpointParams
R
R = E
Parameters
params
The list of params to pass to the fetch strategy. It overrides the ones in the URL.
{ } | Params
fetchStrategy
AbstractFetchStrategy<E, Params, R>
The fetch strategy.
options
FetchHookOptions<FetchResponse<R>> = {}
The options to pass to the swr hook.
path
string = ''
The path of the url to get url params from.
Returns
data
data:
undefined|FetchResponse<R>
The returned data of the fetcher function.
error
error:
any
The error object thrown by the fetcher function.
isLoading
isLoading:
boolean
isMainQuery
isMainQuery:
boolean
isValidating
isValidating:
boolean
mutate
mutate:
KeyedMutator<FetchResponse<R>>
params
params:
Partial<Params> =finalParams