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

449
Vistas
How do I catch GotError [HTTPError]: Response code 404 (Not Found) in nodejs

Assuming that the url provided is wrong, the Got module raises a HTTPError, how do I catch the error? Try catch doesn't work

const got = require('got');
got(`https://www.wrongurl.com`)
                .then(response => {
                    //do stuff
                })
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I would use

got(...).then(
  response => { /* handle good response here */}, 
  error => { /* handle error here */ }
)

Simple .catch(() => { ... }) may catch an error in .then(response... part as well, that's not what you expect.

Also see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then for reference.

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