I want to get date form getters in router. I have 2 modules in my store:
export default function (/* { ssrContext } */) {
const Store = new Vuex.Store({
modules: {
customers,
auth
},
namespaced: true,
strict: process.env.DEV
})
return Store
}
And this is my auth/index.js
import state from "./state";
import * as getters from "./getters"
import * as mutations from "./mutations"
import * as actions from "./actions"
export default {
namespaced: true,
state,
mutations,
actions,
getters
}
I want to check if my user is authenthcated so before go to component I want to check it.
{
path: '',
component: () => import('pages/Index.vue'),
beforeEnter: ifAuthenticated()
},
Now in router/index.js I declare my function
export function ifAuthenticated(to, from, next){
console.log(store.auth); //undefined
if (store.auth.getters.isAuthenticated) {
next();
return;
}
next("/login");
};
How can I call my getters to return value or how can I call my store for auth module?