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

372
Views
Obtener resultados de llamadas en net::ERR_CONNECTION_REFUSED, cómo obtener otro servidor cuando surge un error

Estoy desarrollando una aplicación en javascript que requiere que realice llamadas de búsqueda a un servidor secundario cuando el principal está inactivo. He cerrado el servidor principal para que la aplicación obtenga el servidor secundario. La llamada de búsqueda para mi primer esfuerzo se parece a esto.

 try { fetch(`https://server1`) .then(response => { if (!response.ok) { fetch(`https://server2`) .then(response => { return response.text(); }) } return response.text(); }) } catch (err) { }

Como apagar el servidor da como resultado net::ERR_CONNECTION_REFUSED, no sucede nada en el error de captura. También intenté agregar una variable de bandera y hacer que se ejecute para obtener el primer servidor y luego el segundo como resultado del valor de la bandera:

 var flag = false; try { fetch(`https://server1`) .then(response => { if (response.ok) { flag = true; } return response.text(); }) .catch((err) => { flag = true; }); if (!flag) { fetch(`https://server2`) .then(response => { if (response.ok) { flag = false; } return response.text(); }); } }

Cualquier consejo apreciado. Gracias.

about 4 years ago · Juan Pablo Isaza
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!