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
FetchAPI Response on DNS failure

I am trying something like:

const resp = await fetch('http://bad-domain'); //bad-domain does not resolve

I am then catching an exception later in my code that reads: TypeError: failed to fetch

Is this the expected result of a failed DNS lookup or is this due to resp coming out as different from the normal Response object that an error free fetch returns.

It is just that TypeError does not clearly indicate that the issue is a bad network request and not bad javascript code.

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

0

It's the expected behavior:

12.3. If response is a network error, then reject p with a TypeError and terminate these substeps.

...where p is the promise returned by fetch. The specification doesn't require any specific information be provided about why the request failed, just that it failed (at the network level; it doesn't reject on HTTP errors, as I describe here on my old anemic blog, you have to check that on the fulfillment path).

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