Vuex is a lot of boilerplate.
Consider this user store -
//store/user.js import axios from "axios"; export default { namespaced: true, name: "users", state: { users: [], loading: false, error: "" }, mutations: { setUsers(state, users) { state.users = users; }, setLoading(state, loading) { state.loading = loading; }, setError(state, error) { state.error = error; } }, actions: { fetchUsers({ commit, state }, params) { commit("setLoading", true); commit("setError", ""); axios .get("http://myServer.com/api/get-users") .then(({ data }) => { commit("setUsers", data); }) .catch(e => { commit("setError", "Error fetching user records."); }) .finally(commit("setLoading", false)); } } }; Access this store from your view or component -
<!-- views/User.vue --> <template> <p v-if="error" class="error">{{error }}</p> <p> {{ users }} </p> </template> <script> import { mapState, mapMutations, mapActions } from "vuex"; export default { computed: { ...mapState("user", ["users", "error"]) // states are now accessible as any other computed property }, methods: { ...mapMutations("user", ["setError"]), ...mapActions("user", ["fetchUsers"]) // actions and mutations from store are now accessible // .. as any other methods }, mounted() { this.fetchUsers(); } }; </script> Getting state within components and invoking mutations is laborious and not-so-pretty. If you want to just set one array ‘users’ you need a mutation (setUsers), a state (users), and an action requiring this state. The views and components dependent on the store will use these states and methods - this is way lot of work.
...