Now that we've created our modules, we will add them to the Vuex store. We can integrate the new modules with our old code. This is not a problem because Vuex will handle the new module as a namespaced object, with a completely separate Vuex store.
Now in these steps, we will add the created modules to the Vuex:
- Open the index.js file in the src/store folder.
- Import the index.js file from the authentication folder:
import Vue from 'vue';
import Vuex from 'vuex';
import UserStore from './user';
import Authentication from './authentication';
- In the Vuex.Store function, add a new property called modules, which is a JavaScript object. Then add the imported User and Authentication modules:
export default new Vuex.Store({
...UserStore,
modules: {
Authentication,
}
})