NuxtN
Nuxt2y ago
dwol

Calling `useRoute` within "middleware may lead to misleading results" when watching "locale"

Console warning when watching locale in a useAsyncData call.

console warning: "index.vue:17 [nuxt] Calling useRoute within middleware may lead to misleading results. Instead, use the (to, from) arguments passed to the middleware to access the new and old routes."

I am using this call to query nuxt-content and watching the locale to auto refetch
const { data } = await useAsyncData(
  'some-id',
  () => {
    return queryContent()
      .where({ _locale: locale.value,    _extension: { $eq: 'yml' }, _path: {       $contains: 'some-path' } })
      .findOne()
  },
  {
    watch: [locale]
  }
)

But when I change the locale I get the warning posted above. Is this safe to ignore? I only get the error when changing the locale with 'switchLocalePath', not when I manually change the locale, but then I lose out on lazy loading and need to manually update the route.path
Was this page helpful?