fix(nuxt): don't warn when data fetching in middleware (#28604)

This commit is contained in:
Daniel Roe 2024-08-19 20:37:10 +01:00 committed by GitHub
parent 3ec103b1d4
commit 17bae9b327
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -350,7 +350,7 @@ export function useAsyncData<
if (import.meta.client) {
// Setup hook callbacks once per instance
const instance = getCurrentInstance()
if (import.meta.dev && !nuxtApp.isHydrating && (!instance || instance?.isMounted)) {
if (import.meta.dev && !nuxtApp.isHydrating && !nuxtApp._processingMiddleware /* internal flag */ && (!instance || instance?.isMounted)) {
// @ts-expect-error private property
console.warn(`[nuxt] [${options._functionName || 'useAsyncData'}] Component is already mounted, please use $fetch instead. See https://nuxt.com/docs/getting-started/data-fetching`)
}