Hi I know there are a lot of similar answers on the site, but I still cannot debug why my then is not running in my case. Can you please take a look, it is a very simple code.
let getDuration = new Promise(() => {
durationRetrieveHandler("text_duration", sumDuration);
})
getDuration.then(() => {
console.log('then is running!!!')
}
}).catch((e)=>{
console.log("error occur: " + e);
})
Here in code, durationRetrieveHandler() run perfectly without a mistake, catch() is not running at all (meaning there is no error).
durationRetrieveHandler() is a function use fetch() API to GET some data from DB, sumDuration is a callback insides durationRetrieveHandler().
durationRetrieveHandler() and sumDuration() is below for your reference
function durationRetrieveHandler(sheet, callback) {
getHandler("https://some.url")
.then(function(data){
console.log(data);
return callback(data);
})
.catch(function(error) {
console.log(error);
})
}
function sumDuration(data) {
// sum things up, no return
}
Thank you so much for the help, I will be super super appreciate!!!