Cannot use vuex store getters from nuxt.js Middleware

Viewed 3340

I have getters setup within my Vuex store that I can access. I can also see the getters if I output the context.store.getters object in the console from my Middleware.

The problem is that if I try to actually use the getters in my Middleware (e.g., context.store.getters.userType) I receive errors that they are undefined. Is there anyway to access the getters from middleware?

Here is my middleware:

export default function (context) {
  console.log("context.store.getters", context.store.getters);
  console.log("context.store.getters.getUserType", 
  context.store.getters.getUserType)

  if (context.store.getters.getUserType == "adv") {
    return router.push('/adv')
  } else if (context.store.getters.getUserType == "applicant") {
    return router.push('/app')
  }
}

However, you can see that there is actually a defined and resultant "userType" getter in the store via the console: enter image description here Thanks for the help.

0 Answers
Related