0👍
Provided your action returns a value or a promise that resolves with the value you want, eg
actionOne: async ({ commit }, payload) => {
// do something async, commit values, etc
return actionResponse
}
then you can keep chaining promises like so
axios.get(data.url)
.then(({ data }) => context.dispatch("actionOne", data))
.then(actionResponse => context.dispatch("actionTwo", actionResponse))
Note the implicit return value from the arrow functions. The .then()
method always returns a new promise that resolves with the return
value.
In longer form, this looks like
axios.get(data.url)
.then(({ data }) => {
return context.dispatch("actionOne", data))
})
.then(actionResponse => {
return context.dispatch("actionTwo", actionResponse))
})
- [Vuejs]-Add/Edit list item at parent from child component form
- [Vuejs]-Emitting Event from node_modules to vue
Source:stackexchange.com