1

I need to access a variable from my store in my router. This variable is called 'isAdmin'. Now, when I'm using the following code, I'm getting the initial state (which has the value of 'false'):

console.log(store.state.isAdmin)

Although I've updated the 'isAdmin' value to 'true' committing an action, the state of 'isAdmin' continues to be as the initial state.

Now, if I console.log the following object:

console.log(store.state)

I see this:

How to get isAdmin from there?

My question is: How do I get to the value of isAdmin after I've amended it in my store?

Thank you!!!

  • Can you share the code you're using for the router to use the store? – Frondor Jun 13 '18 at 07:53
  • This is what I have in the router.js: `import Vue from 'vue'; import Router from 'vue-router'; import store from './store'`; – Alexandru Popovici Jun 13 '18 at 07:57
  • No, we must know the context in which you're calling `console.log`... The router is not reactive, so you shouldn't expect things to be reactive there. But it will track the changes once a navigation cycle occurs. Edit your answer with the full example. – Frondor Jun 13 '18 at 08:00
  • Line 37: http://take.ms/XRo8c – Alexandru Popovici Jun 13 '18 at 08:11
  • See this: https://stackoverflow.com/questions/42603909/accessing-vuex-state-when-defining-vue-router-routes – Laszlo T Sep 17 '18 at 17:58

0 Answers0