Accessing to store in the router
-
Hello Quasar lovers,
I got an issue with my router (or store ?). I can’t access to data in the store before entering a route.
Just in case, i made a topic in stackoverflow too: https://stackoverflow.com/questions/65144080/accessing-to-store-in-the-router/65145838#65145838
But I prefer to create a topic here because I am pretty sure you can help me.Last week I worked on the store, but It was really hard for me (I’m used to work on Vuejs 2.0 with Vuex) but with Quasar it was so hard (for my collegue and me) to find how to work with this Vuex (from Quasar) syntax. So I finally reinstalled Vuex (with NPM, not with Quasar CLI) and my store is working great with my components.
I can just use this syntaxe properly in the components:...mapGetters(['userInfos'])
But now, I got this issue that i can’t access to the data in the store from the router. and i’m starting guessing that IS BECAUSE I reinstalled vuex.
Or maybe because I don’t see any module name prefix in the consolelog, even NOT in the vue developer tool, that’s why I can’t consolelog like that:store.getters['user/userInfos']
Probably because the name of the module isn’t declared somewhere?
Maybe can you guys confirm?here the details of the problem:
When I console.log(store.myStore.getters) I can see everything:
But when I console.log(store.myStore.getters.userInfos), I don’t see anything:
There are the files of the router (2 files) and store (2 files):
Index.ts (store) : https://codeshare.io/G8m6Qj
module: user.js : https://codeshare.io/5eAekLindex.ts (routeur) : https://codeshare.io/29lwJB
routes.ts : https://codeshare.io/aJEYmyThank you!
-
@jerlive said in Accessing to store in the router:
So I finally reinstalled Vuex (with NPM, not with Quasar CLI)
Don’t think this is a good idea. Please remove the npn installed version of vuex. For the rest of this thread I assume you have done this.
I can’t access to data in the store before entering a route.
your
store/index.ts
exports a store module instead of an actual store. I suspect thesrc/store/index.js|ts
file must export a store for Quasar to work properly with vuex.