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

108
Vistas
Separate different failures when using fetch

I am using fetch to make requests to the backend of my application, which uses an OAuth authentication provider.

When the session expires, the fetch request is redirected to the authentication provider, causing it to fail because of a CORS error (which I cannot change).

In this case, fetch throws a TypeError: failed to fetch. Unfortunately, I am also getting a TypeError: failed to fetch, when the network is down or the request times out for another reason.

How can I reliably discriminate between these failure modes?

I have not found any useful properties on the thrown TypeError, that would allow these failures to be distinguished.

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

0

It is possible to catch redirects using the redirect: "manual" option.

fetch(url, {redirect: "manual"})

While it is not possible to catch the redirection URL for security purposes, this is an acceptable resolution for me at this point.

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