[Vuejs]-Calling a mixin function from the store

0👍

Try this:
Call the action like this:

this.$store.dispatch('store/get')
 .then(r => {
        // r contains the result, but you can call here the getter as well..
    })
 .catch(e => {
        // catch every error here, you can handle here the error.
});

And the getter function is like this:

get: function(context) {
   return axios.get(/api/call/get)
    .then(r => {
        ... // mutations, conditions of data check.. throwing errors..
        return r;
    })
    .catch(e => {
        throw e;
    })
}

I hope my thought is clear, but if it is not, comment your question(s)! 🙂

Leave a comment