[Vuejs]-Vuex unknown action type: ADD_ARTICLE

1πŸ‘

βœ…

In your store you declared an addArticle action but you are importing ADD_ARTICLE.

You just need to change it like that :

  import { mapActions } from "vuex";
    export default {
      data() {
        return {
          title: ""
        };
      },
      methods: {
        ...mapActions(["addArticle"]),
        passToDB() {
          this.addArticle(this.title);
        }
      }
    };

As pointed by @Eugen Govorun by default namespacing is turned off.
If you turned it on by doing :

    export default {
        state,
        getters,
        actions,
        mutations,
        namespaced: true
    };

You would have used your Action by doing so :

  import { mapActions } from "vuex";
    export default {
      data() {
        return {
          title: ""
        };
      },
      methods: {
        ...mapActions("article", ["addArticle"]),
        passToDB() {
          this.addArticle(this.title);
        }
      }
    };

Because you are importing your module with the name article.

πŸ‘€Pierre Said

0πŸ‘

By default namespacing is turned off. There is no ADD_ARTICLE action in your article module. Just mutation with such a name. Your action name actually is addArticle.

πŸ‘€Eugen Govorun

Leave a comment