Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

92
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda