mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
docs: add await
before lazy composable examples
This commit is contained in:
parent
95a0e17898
commit
7e7e006e9b
@ -58,9 +58,9 @@ This composable behaves identically to `useFetch` with the `lazy: true` option s
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
const { pending, data: posts } = useLazyFetch('/api/posts')
|
||||
const { pending, data: posts } = await useLazyFetch('/api/posts')
|
||||
watch(posts, (newPosts) => {
|
||||
// Because posts starts out null, you will not have access
|
||||
// Because posts might start out null, you will not have access
|
||||
// to its contents immediately, but you can watch it.
|
||||
})
|
||||
</script>
|
||||
@ -119,7 +119,7 @@ This composable behaves identically to `useAsyncData` with the `lazy: true` opti
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
const { pending, data: count } = useLazyAsyncData('count', () => $fetch('/api/count'))
|
||||
const { pending, data: count } = await useLazyAsyncData('count', () => $fetch('/api/count'))
|
||||
watch(count, (newCount) => {
|
||||
// Because count starts out null, you won't have access
|
||||
// to its contents immediately, but you can watch it.
|
||||
@ -231,7 +231,7 @@ This method is useful if you want to refresh all the data fetching for a current
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
const { pending, data: count } = useLazyAsyncData('count', () => $fetch('/api/count'))
|
||||
const { pending, data: count } = await useLazyAsyncData('count', () => $fetch('/api/count'))
|
||||
|
||||
const refresh = () => refreshNuxtData('count')
|
||||
</script>
|
||||
|
@ -27,10 +27,10 @@ By default, [useAsyncData](/docs/api/composables/use-async-data) blocks navigati
|
||||
/* Navigation will occur before fetching is complete.
|
||||
Handle pending and error states directly within your component's template
|
||||
*/
|
||||
const { pending, data: count } = useLazyAsyncData('count', () => $fetch('/api/count'))
|
||||
const { pending, data: count } = await useLazyAsyncData('count', () => $fetch('/api/count'))
|
||||
|
||||
watch(count, (newCount) => {
|
||||
// Because count starts out null, you won't have access
|
||||
// Because count might start out null, you won't have access
|
||||
// to its contents immediately, but you can watch it.
|
||||
})
|
||||
</script>
|
||||
|
@ -32,9 +32,9 @@ By default, [useFetch](/docs/api/composables/use-fetch) blocks navigation until
|
||||
/* Navigation will occur before fetching is complete.
|
||||
Handle pending and error states directly within your component's template
|
||||
*/
|
||||
const { pending, data: posts } = useLazyFetch('/api/posts')
|
||||
const { pending, data: posts } = await useLazyFetch('/api/posts')
|
||||
watch(posts, (newPosts) => {
|
||||
// Because posts starts out null, you won't have access
|
||||
// Because posts might start out null, you won't have access
|
||||
// to its contents immediately, but you can watch it.
|
||||
})
|
||||
</script>
|
||||
|
@ -62,7 +62,7 @@ This example below refreshes only data where the key matches to `count`.
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
const { pending, data: count } = useLazyAsyncData('count', () => $fetch('/api/count'))
|
||||
const { pending, data: count } = await useLazyAsyncData('count', () => $fetch('/api/count'))
|
||||
const refresh = () => refreshNuxtData('count')
|
||||
</script>
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user