Skip to content

Commit 7e7e006

Browse files
committed
docs: add await before lazy composable examples
1 parent 95a0e17 commit 7e7e006

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

docs/1.getting-started/6.data-fetching.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ This composable behaves identically to `useFetch` with the `lazy: true` option s
5858
</template>
5959
6060
<script setup>
61-
const { pending, data: posts } = useLazyFetch('/api/posts')
61+
const { pending, data: posts } = await useLazyFetch('/api/posts')
6262
watch(posts, (newPosts) => {
63-
// Because posts starts out null, you will not have access
63+
// Because posts might start out null, you will not have access
6464
// to its contents immediately, but you can watch it.
6565
})
6666
</script>
@@ -119,7 +119,7 @@ This composable behaves identically to `useAsyncData` with the `lazy: true` opti
119119
</template>
120120
121121
<script setup>
122-
const { pending, data: count } = useLazyAsyncData('count', () => $fetch('/api/count'))
122+
const { pending, data: count } = await useLazyAsyncData('count', () => $fetch('/api/count'))
123123
watch(count, (newCount) => {
124124
// Because count starts out null, you won't have access
125125
// 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
231231
</template>
232232
233233
<script setup>
234-
const { pending, data: count } = useLazyAsyncData('count', () => $fetch('/api/count'))
234+
const { pending, data: count } = await useLazyAsyncData('count', () => $fetch('/api/count'))
235235
236236
const refresh = () => refreshNuxtData('count')
237237
</script>

docs/3.api/1.composables/use-lazy-async-data.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ By default, [useAsyncData](/docs/api/composables/use-async-data) blocks navigati
2727
/* Navigation will occur before fetching is complete.
2828
Handle pending and error states directly within your component's template
2929
*/
30-
const { pending, data: count } = useLazyAsyncData('count', () => $fetch('/api/count'))
30+
const { pending, data: count } = await useLazyAsyncData('count', () => $fetch('/api/count'))
3131
3232
watch(count, (newCount) => {
33-
// Because count starts out null, you won't have access
33+
// Because count might start out null, you won't have access
3434
// to its contents immediately, but you can watch it.
3535
})
3636
</script>

docs/3.api/1.composables/use-lazy-fetch.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ By default, [useFetch](/docs/api/composables/use-fetch) blocks navigation until
3232
/* Navigation will occur before fetching is complete.
3333
Handle pending and error states directly within your component's template
3434
*/
35-
const { pending, data: posts } = useLazyFetch('/api/posts')
35+
const { pending, data: posts } = await useLazyFetch('/api/posts')
3636
watch(posts, (newPosts) => {
37-
// Because posts starts out null, you won't have access
37+
// Because posts might start out null, you won't have access
3838
// to its contents immediately, but you can watch it.
3939
})
4040
</script>

docs/3.api/3.utils/refresh-nuxt-data.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ This example below refreshes only data where the key matches to `count`.
6262
</template>
6363
6464
<script setup>
65-
const { pending, data: count } = useLazyAsyncData('count', () => $fetch('/api/count'))
65+
const { pending, data: count } = await useLazyAsyncData('count', () => $fetch('/api/count'))
6666
const refresh = () => refreshNuxtData('count')
6767
</script>
6868
```

0 commit comments

Comments
 (0)