fix(nuxt): await asyncData if ssr: false (#4791)

This commit is contained in:
Daniel Roe 2022-05-06 12:04:01 +01:00 committed by GitHub
parent b29f635646
commit 87c62513fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -144,7 +144,7 @@ export function useAsyncData<
if (fetchOnServer && nuxt.isHydrating && key in nuxt.payload.data) {
// 1. Hydration (server: true): no fetch
asyncData.pending.value = false
} else if (instance && (nuxt.isHydrating || options.lazy)) {
} else if (instance && nuxt.payload.serverRendered && (nuxt.isHydrating || options.lazy)) {
// 2. Initial load (server: false): fetch on mounted
// 3. Navigation (lazy: true): fetch on mounted
instance._nuxtOnBeforeMountCbs.push(initialFetch)