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

150
Views
Cómo mostrar el mensaje de error solo una vez cuando se da el código de estado 500
useEffect(() => { setTimeout(async () => { await fetch(url) .then((res) => res.json()) .then((data) => { if (Object.keys(data).length !== 0) { setIsLoaded(true); setRoundTrip(data); } else { Swal.fire({ icon: "error", title: "Oops...", text: "No Flights Found", confirmButtonText: "Search Again...", }) .then(function () { navigate("/"); }); } }); }, 1000); }, [url]);

Me da el mensaje de error varias veces, pero quiero mostrar el mensaje de error solo una vez, entonces debería dejar de buscar.

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

0

Puede establecer condiciones para res.status.

 useEffect(() => { setTimeout(async () => { await fetch(url) .then((res) => res.json()) .then((data) => { //here is solution if(res.status === 500){ Swal.fire({ icon: "error", title: "Oops...", text: "No Flights Found", confirmButtonText: "Search Again...", }) .then(function () { navigate("/"); }); } if (Object.keys(data).length !== 0) { setIsLoaded(true); setRoundTrip(data); } }); }, 1000); }, [url]);
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!