Is there a method to determine if the action dispatched from a component has completed without utilizing state management? Currently, I have an action called createAddress. In my component, there is a modal where users input their address. Once the user enters the details and clicks on the 'Save' button, I dispatch the action as shown below -
saveAddress () {
this.$store.dispatch('createAddress', this.address)
}
The action triggers an axios call which returns either a status of 200 OK or an error. If the status is 200, I want to close the modal. If there is an error, I do not want to close it. What would be the most effective way to achieve this task? Do I really need to create a separate state, update its value, monitor that value in the component, and then decide whether to close the modal?
Below is the desired outcome in terms of code:
saveAddress () {
this.$store.dispatch('createAddress', this.address)
// Close modal upon success
}