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

171
Views
How simulate request errors?

So, I read the article: "How to Handle API Errors"

In this article, it is proposed to divide errors into:

if (err.response) { 
      // client received an error response (5xx, 4xx)
    } else if (err.request) { 
      // client never received a response, or request never left 
    } else { 
      // anything else 
    } 

Ok, but how i can test this?

  • Response errors are pretty easy. I use Mokku chrome extension.
  • Else errors i can simulate with chrome dev tools 'network request blocking' tab.

But what about request Errors? How can i simulate this error on frontend?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

What you need is a testing framework, which could be something like Jest. Using a testing framework, you can mock the request to return an error you choose.

Heres a post with an answer which might be the same as your issue.

Mock Axios to test .catch()

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!