I'd like to trigger a specific action when an ajax call is successful in axios
save() {
this.isUpdateTask ? this.updateProduct() : this.storeProduct()
this.endTask()
}
When the ajax call to update or store the product succeeds, I want to execute the endTask() function.
I only want the endTask() function to be executed if the ajax call is successful.
How can I achieve this?
The store function:
storeProduct() {
return axios
.post("products", this.getFormData())
.then(
response => this.products.push(response.data.data)
)
.catch(
error => (this.serverErrors = error.response.data.errors.detail)
)
},