NuxtN
Nuxtβ€’15mo agoβ€’
5 replies
Omnislash

Nuxt Context error despite onNuxtReady

Hello

I have the following error :
Uncaught Error: [nuxt] A composable that requires access to the Nuxt instance was called outside of a plugin, Nuxt hook, Nuxt middleware, or Vue setup function. This is probably not a Nuxt bug. Find out more at
https://nuxt.com/docs/guide/concepts/auto-imports#vue-and-nuxt-composables
.

Problem is, the error is from this code (in a composable) :
    constructor() {
        onNuxtReady(async () => {
            this._getAuth()
            if (this.isAuthenticated && this.isExpired)
                this.logout()
        })
    }


Isn't the goal of onNuxtReady to avoid this problem ? what am I doing wrong ?

Thanks πŸ™‚
Was this page helpful?