Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

84
Views
Promise.then then not run

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!!!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!