I have a complex if-else condition in my code that includes different promises. Once the logic determines which condition to enter and executes the corresponding promise, I need to ensure that a final promise is always executed.
if (a < 5)
{
vm.promise1()
.then((data) => {
//handle data
})
}
else if (a > 5)
{
vm.promise2()
.then((data) => {
//handle data
})
}
else
{
vm.promise3()
.then((data) => {
//handle data
})
}
Now, I want to ensure that vm.finalPromise() is executed after any of the conditions are met. Is there a way to achieve this without having to use .finally() on each individual promise?
Thank you