2022-04-06 05:56:08 +00:00
# `useLazyAsyncData`
2022-04-14 10:45:53 +00:00
## Description
2022-04-14 08:53:58 +00:00
2022-04-14 10:45:53 +00:00
By default, [useAsyncData ](/api/composables/use-async-data ) blocks navigation until its async handler is resolved.
2022-04-06 05:56:08 +00:00
2022-04-14 10:45:53 +00:00
`useLazyAsyncData` provides a wrapper around `useAsyncData` that triggers navigation before the handler is resolved by setting the `lazy` option to `true` .
> `useLazyAsyncData` has the same signature as `useAsyncData`.
:ReadMore{link="/api/composables/use-async-data"}
2022-04-06 05:56:08 +00:00
2022-04-14 08:53:58 +00:00
## Example
```vue
< template >
< div >
{{ pending ? 'Loading' : count }}
< / div >
< / template >
< script setup >
2022-04-14 10:45:53 +00:00
/* Navigation will occur before fetching is complete.
Handle pending and error state directly within your component's template
*/
2022-04-14 08:53:58 +00:00
const { pending, data: count } = useLazyAsyncData('count', () => $fetch('/api/count'))
2022-04-14 10:45:53 +00:00
2022-04-14 08:53:58 +00:00
watch(count, (newCount) => {
// Because count starts out null, you won't have access
// to its contents immediately, but you can watch it.
})
< / script >
```
2022-04-14 10:45:53 +00:00
:ReadMore{link="/guide/features/data-fetching#uselazyasyncdata"}