useLazyAsyncData provides a wrapper around useAsyncData that triggers navigation before the handler is resolved by setting the lazy option to true.
By default,
useAsyncData blocks navigation until its async handler is resolved. useLazyAsyncData allows navigation to occur immediately while data fetching continues in the background.Usage
[app/pages/index.vue]
useLazyAsyncData, navigation will occur before fetching is complete. This means you must handle pending and error states directly within your component’s template.
Parameters
useLazyAsyncData accepts the same parameters as useAsyncData, with the lazy option automatically set to true.
A unique key to ensure that data fetching can be properly de-duplicated across requests.
An asynchronous function that returns the data.
Same options as
useAsyncData, with lazy automatically set to true. See useAsyncData parameters for details.Return Values
useLazyAsyncData returns the same values as useAsyncData.
The result of the asynchronous function that is passed in.
A function that can be used to refresh the data returned by the
handler function.An error object if the data fetching failed.
A string indicating the status of the data request.
A boolean that is
true while the request is in progress.A function that can be used to set
data to undefined, set error to undefined, set status to idle, and mark any currently pending requests as cancelled.Example
[app/pages/index.vue]