I am trying to access the value from the VueX Store in beforeEnter hook I tried accessing it directly using the store object or even accessing the getter function via store object but still return empty object even though I can see the value in the store object
async getCurrentUser(to, from, next) {
console.log("getUserState");
console.log(Store.store);
console.log(Store.store.state.auth.user);
console.log("finish");
}
I am using the above method in router.js in beforeEnter hook.
{
path: "/dashboard",
name: "dashboard",
components: {
header: DashboardHeader,
default: Dashboard,
footer: DashboardFooter
},
beforeEnter: Guards.getCurrentUser
}
click here to see output on console of the getCurrentUser function
As you can see that value is there but when I access it directly in the below line it's an empty object. I accessing it in a javascript module which is below
import * as Store from './store/store'
export default {
async getCurrentUser(to, from, next) {
console.log(Store.store);
console.log(Store.store.state.auth.user);
}
}