Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

109
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda