[Vuejs]-Can't dispatch action defined in store sub file

0๐Ÿ‘

/store/modules/auth.js

import Vue from "vue";
import Vuex from "vuex";
import auth from "./modules/auth";

export default new Vuex.Store({
  state: {
    token: null
  },
  getters: {},
  mutations: {},
  actions: {},
  modules: {
    auth: { // it's registry name, will be used while accessing module content.
        namespaced: true,
        ...auth // actual module content.
    }
  }
});

While registering the module, you are not providing the actual module
content.

Ref vue doc: https://vuex.vuejs.org/guide/modules.html#namespacing

Leave a comment