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

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

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 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!