From 17bae9b327ccd85af9b0ba1f3e98150bcd08a8f9 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Mon, 19 Aug 2024 20:37:10 +0100 Subject: [PATCH] fix(nuxt): don't warn when data fetching in middleware (#28604) --- packages/nuxt/src/app/composables/asyncData.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nuxt/src/app/composables/asyncData.ts b/packages/nuxt/src/app/composables/asyncData.ts index 67d8b169e8..8c050f48e4 100644 --- a/packages/nuxt/src/app/composables/asyncData.ts +++ b/packages/nuxt/src/app/composables/asyncData.ts @@ -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`) }