Skip to content

Commit

Permalink
fix(nuxt): await nuxt ready state before refreshNuxtData (#21008)
Browse files Browse the repository at this point in the history
  • Loading branch information
lihbr committed May 22, 2023
1 parent 7cc7297 commit a672cd7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/nuxt/src/app/composables/asyncData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = any, Output = any> = (input: Input) => Output

Expand Down Expand Up @@ -300,6 +301,9 @@ export async function refreshNuxtData (keys?: string | string[]): Promise<void>
if (process.server) {
return Promise.resolve()
}

await new Promise<void>(resolve => onNuxtReady(resolve))

const _keys = keys ? Array.isArray(keys) ? keys : [keys] : undefined
await useNuxtApp().hooks.callHookParallel('app:data:refresh', _keys)
}
Expand Down

0 comments on commit a672cd7

Please sign in to comment.