I really need help with this. I am not able to dispatch any actions from router index.ts file.
My store index is like this:
import { createStore } from "vuex";
import { actions } from "./actions";
import { getters } from "./getters";
import { mutations } from "./mutations";
// ...other code here for state and types etc...
export const store = createStore<State>({
state,
actions,
getters,
mutations,
});
Main.ts file has it like:
import {store} from "./store";
const app = createApp(App).use(router).use(store);
// ...other code ...
In router, I have a beforeEach
In side before each if I use something like:
import { store } from "../store";
// ...other code...
router.beforeEach((to, from, next) => {
// ...other code ...
store.dispatch(ActionTypes.SignIn);
// ...other code ...
}
I am getting this error [vuex] unknown action type: SignIn
Syntax is all correct I guess as it works in .vue files. Please help, let me know what I am doing wrong here. I have seen some examples for Vue 2 which work but Vue 3 and Vuex 4 not working for me. I can share more details in code if needed. Thanks in advance. If it works for me I will upvote and accept your answer :) If some can try this same scenario locally please let me know with example.