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

155
Vistas
Will try-catch catch an error if the function inside of it doesn't have an await in front of it?

Imagine I have the following function:

const test = async () => {
    const response = await axios.get('testurl');
    return response;
}

And then I try to use the function like this:

try {
    test();
} catch (error) {
    // handle errors
}

Will the try-catch block actually catch the error if I call the test() function without an await in front of it in the try-catch block?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

No. Without an await the calling function will not go to sleep and wait for the promise to resolve or error. It will continue running to its own completion.

Later, when the promise errors, the error will be unhandled.

about 4 years ago · Juan Pablo Isaza Denunciar
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