I have the following chain of promise, which I expected the resolve function of .finally() to be promise to be returned, but instead the last .then() is the one that gets returned.
exportReportToJson (url,opts) {
const requestJSON = {
"values" : []
};
return this.getValue(url)
.then( value => {
requestJSON.values.push(value);
if(opts.extraValue){
return this.getExtraValue(value);
}else{
return Promise.finally();
}
})
//The index of .push gets returned instead
.then(extraValue => requestJSON.values.push(extraValue))
//But I want requestJSON to always be the returned Promise
.finally( () => requestJSON)
}
As you can see I want finally to always be the final promise to be returned, is that not what is for? What am I missing here? I thought it worked as an .always()
No await please.
I want to have a conditional .then while not changing the final .then basically.