[Vuejs]-Vue.js and django. action, component updating, function execution

0👍

It’s clear from your code that your Result methods return promises. You should return this promise from your actions. For example:

actions = {
    getResult ({commit}, payload) {
       return Result.getResult(payload).then(result => {
            commit(GET_RESULT, {result})
        })
    },
    postResult ({commit}, payload) {
        return Result.postResult(payload)
    }
}

You can then take advantage of the promise to make sure your getResult doesn’t run until after postResult has finished.

this.$store.dispatch('postResult')
.then(() => this.$store.dispatch('getResult'))
👤Mark

Leave a comment