Skip to content

Commit

Permalink
docs: add await before lazy composable examples
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed May 10, 2023
1 parent 95a0e17 commit 7e7e006
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions docs/1.getting-started/6.data-fetching.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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>
Expand Down
4 changes: 2 additions & 2 deletions docs/3.api/1.composables/use-lazy-async-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
4 changes: 2 additions & 2 deletions docs/3.api/1.composables/use-lazy-fetch.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion docs/3.api/3.utils/refresh-nuxt-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>
```
Expand Down

0 comments on commit 7e7e006

Please sign in to comment.