0👍
I’m using module approach in vue store. when I add the imported file to modules object, Module state is wrapped inside the module name.
That’s the expected behavior of your code when you use modules. The state will be wrapped in the module field inside the top state.
Getters defined inside a module (like isLoggedIn
in your case) get that module’s state as the first param (and root state as the third). That’s why state.user
is actually working inside that getter, even if, in your store, the real path to user is state.auth.user
.
If you want user
to be part of the state
directly, you should define it as part of the store’s state, not the auth module.
On the other hand, while the state of every module is placed inside that module, getters are not. So you can call this.$store.getters.isLoggedIn
and it will work.