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

122
Views
Reaccionar recuperación asíncrona con 503 Servicio no disponible

Estoy tratando de obtener datos de 20 usuarios aleatorios de 'https://randomuser.me/api' y, en algunos casos, aparece el error 503 Servicio no disponible.

Traté de resolver el problema con este tipo de código.

 async function fetchDriver() { const driver = await fetch(driverUrl) .then((response) => { if (response.status === 200) { return response.json(); } if (response.status === 503) { return fetchDriver(); } }) .then((data) => console.log(data)) .catch((error) => { console.log(error); fetchDriver(); }); return driver; } do { const geoPosition = fetchGeoPosition(); const phoneNumber = fetchPhoneNumber(); const licenseNumber = fetchLicense(3); const speed = fetchSpeed(60, 200); const driver = fetchDriver(); const first = driver.name.first; const last = driver.name.last; fetchedCars.push({ licenseNumber, first, last, phoneNumber, geoPosition, speed, favorite: false, more: false, }); } while (fetchedCars.length < 20);

Pero console.log(data) en algunos casos todavía muestra el valor de indefinido y simplemente no sé qué hacer con esto.

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

0

La API de usuario aleatorio tiene un limitador de velocidad. use esto para obtener múltiples usuarios en una solicitud (por ejemplo, 20 usuarios):

https://randomuser.me/api/?results=20

revisa la documentación aquí

Este hilo de GitHub menciona la limitación de velocidad y la solución que he incluido

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!