useLazyFetch provides a wrapper around useFetch that triggers navigation before the handler is resolved by setting the lazy option to true.
By default, useFetch blocks navigation until its async handler is resolved. useLazyFetch allows navigation to proceed immediately, with data being fetched in the background.
Usage
[app/pages/index.vue]
useLazyFetch has the same signature as useFetch.Parameters
useLazyFetch accepts the same parameters as useFetch:
The URL or request to fetch.
Same as
useFetch options, with lazy automatically set to true. See useFetch parameters for full details.Return Values
Returns the sameAsyncData object as useFetch:
The result of the asynchronous fetch.
Function to manually refresh the data.
Alias for
refresh.Error object if the data fetching failed.
Status of the data request.
Resets
data to undefined, error to undefined, sets status to idle, and cancels any pending requests.Examples
Handling Pending State
[app/pages/index.vue]
Type
useLazyFetch is equivalent to useFetch with lazy: true option set.