Is there any way to know if the dispatched action from a component has completed or not without setting a state? Right now I have an action - createAddress In my component, I have a modal where the user enters address. When the user enters the details and clicks on 'Save' button, I dispatch the action like this -
saveAddress () {
this.$store.dispatch('createAddress', this.address)
}
The action makes an axios call and returns either status 200 OK or error. If status 200 I want to close the modal. If error, I don't want to close it. What is the best way to achieve this? Do I really have to create a state, update that state value, watch that value in the component and then close the modal?
Below is what I want from code point of view
saveAddress () {
this.$store.dispatch('createAddress', this.address)
// Close modal if success
}