Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

107
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!