0๐
.then() and .catch() are both functions, so I would just create a new method with your repetitive code. Something like:
methods: {
save () {
var self = this
return this.saveEvent(payload)
.then(() => { self.resetForm() })
.catch(resp => {
if (resp.status === 400) {
self.repetitiveTask()
}
})
},
repetitiveTask () {
// verry repetitive task!!
}
}
I did var self = this
so you can call the repetitiveTask()
method in a different scope.
- [Vuejs]-Switch divs by clicking on checkbox (Vue.js)
- [Vuejs]-How to separate node modules from async chunks in webpack?
Source:stackexchange.com