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
parent dba2b972bd
commit 2fcadda2e5
No known key found for this signature in database
GPG Key ID: CBC814C393D93268

View File

@ -363,7 +363,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`)
}