mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +00:00
use async/await
This commit is contained in:
parent
be07940021
commit
a61a14ad92
@ -1,6 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useSharedAsyncData } from '../composables/asyncDataTests'
|
import { useSharedAsyncData } from '../composables/asyncDataTests'
|
||||||
const { data, pending } = useSharedAsyncData()
|
const { data, pending } = await useSharedAsyncData()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -6,10 +6,10 @@ export const useSleep = () => useAsyncData('sleep', async () => {
|
|||||||
|
|
||||||
export const useCounter = () => useFetch('/api/useAsyncData/count')
|
export const useCounter = () => useFetch('/api/useAsyncData/count')
|
||||||
|
|
||||||
export const useSharedAsyncData = () => {
|
export const useSharedAsyncData = async () => {
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
|
||||||
const { data, execute, pending } = useAsyncData(
|
const { data, execute, pending } = await useAsyncData(
|
||||||
'sharedAsyncData',
|
'sharedAsyncData',
|
||||||
() => Promise.resolve('some data'),
|
() => Promise.resolve('some data'),
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
import { useSharedAsyncData } from '../../composables/asyncDataTests'
|
import { useSharedAsyncData } from '../../composables/asyncDataTests'
|
||||||
import ComponentWithSharedUseAsyncData from '../../components/ComponentWithSharedUseAsyncData.vue'
|
import ComponentWithSharedUseAsyncData from '../../components/ComponentWithSharedUseAsyncData.vue'
|
||||||
|
|
||||||
const { data, pending, execute } = useSharedAsyncData()
|
const { data, pending, execute } = await useSharedAsyncData()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
const page = ref(1)
|
const page = ref(1)
|
||||||
|
Loading…
Reference in New Issue
Block a user