diff --git a/packages/nuxt/src/app/composables/asyncData.ts b/packages/nuxt/src/app/composables/asyncData.ts index a5bd1e882d..dedc712926 100644 --- a/packages/nuxt/src/app/composables/asyncData.ts +++ b/packages/nuxt/src/app/composables/asyncData.ts @@ -3,6 +3,7 @@ import type { Ref, WatchSource } from 'vue' import type { NuxtApp } from '../nuxt' import { useNuxtApp } from '../nuxt' import { createError } from './error' +import { onNuxtReady } from './ready' export type _Transform = (input: Input) => Output @@ -300,6 +301,9 @@ export async function refreshNuxtData (keys?: string | string[]): Promise if (process.server) { return Promise.resolve() } + + await new Promise(resolve => onNuxtReady(resolve)) + const _keys = keys ? Array.isArray(keys) ? keys : [keys] : undefined await useNuxtApp().hooks.callHookParallel('app:data:refresh', _keys) }