[Vuejs]-Unknow action type error using vuex store

1👍

You can simply call the actions with the action name like this

created() {
    this.$store.dispatch('fetchTechValids');
}

You don’t need to specify the module name while calling actions and mutations.

And inside the action function, you can call the mutations like

actions: {
  async fetchTechValids({commit}) {
     let response = await axios.get('http://localhost:3080/techValid'); // since async function is using, you can directly get the response.
     console.log('API CALL OK');
     console.log(response);
     commit('SET_ALL_TECHVALIDS', response);
  },
}

You can use if condition to before calling the commit and can use the try-catch to catch the errors.

👤Rijosh

0👍

Ok thanks to all of you!

It works now, I removed the module name in my dispatch : this.$store.dispatch('fectTechValids')

And removed the namespaced in my store and just export state, getters, mutations, actions

Leave a comment