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

216
Views
Axios obtiene el estado de solicitud 503 si lo llamo dentro de un bucle for

Quiero hacer diez llamadas a la API para completar una matriz. Si hago la misma llamada a la API pero fuera del bucle for, no tengo ningún problema. Pero al hacerlo dentro del ciclo for, recibo algunas solicitudes exitosas y una tonelada con un código de estado 503, el servicio no está disponible.

Aquí está mi js:

 function generatePersonJson() { const promise = axios.get(url, { headers: { Accept: "application/json", "User-Agent": "axios 0.21.1", }, }); const dataPromise = promise.then((response) => response.data); return dataPromise; } const createPerson = async () => { generatePersonJson() .then((data) => { if (data) { return data } }) .catch((err) => console.log(err)); }; const createPersons = async () => { let personsArray = []; for (let i = 0; i < 11; i++) { const person = await createPerson(); personsArray.push(person); } console.log(personsArray); }; createPersons();

Recibo el error en el bloque catch dentro de createPerson y se ve así: response: { status: 503, statusText: 'Service Unavailable',

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!