In my VueCLI project, I have the following code snippet inside my methods:
submitCheck: function () {
function authUser() {
// returns a promise
}
function uploadFile() {
// also returns a promise
}
// ...
if ( error !== null ) {
EventBus.$emit('showError', error)
} else {
authUser()
.then(
function () {
return uploadFile();
})
.then(
function (data) {
EventBus.$emit('loaderStop')
this.$router.push('/awaiting');
})
.catch(function(error) {
EventBus.$emit('loaderStop')
console.log(error)
})
}
I am trying to figure out how to route to /awaiting once all promises are resolved. The issue is that since I am using this inside an anonymous function, I do not have access to the router. I'm sure many developers have encountered similar challenges and needed to navigate within a function. Any suggestions on how to accomplish this?
Kalreg.