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

190
Views
¿Cómo limito las llamadas de recuperación realizadas a un servicio de terminal para que no se realicen más de 10 llamadas por segundo?

Para evitar el error "Error 429 Too Many Requests" en el navegador, ¿cómo puedo modificar el siguiente código para que no se realicen más de 10 llamadas por segundo?

Este límite de frecuencia de 10 llamadas por segundo lo impone una API de terceros, sobre la cual no tenemos control.

¡Gracias por adelantado!

 // Array of hundreds of URLS const urls = allNames.map( (name) => `https://example.com/api/v3/results/${name}?limit=120&apikey=123` ); // TODO add throttle so as to not exceed 10 calls per second const getStaticProps = async () => { Promise.allSettled( urls.map((url) => fetch(url).then((resp) => resp.json()) ) ).then(console.log); };
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Puedes buscar diez y esperar un segundo.

 // Array of hundreds of URLS const urlsList = allNames.map( (name) => `https://example.com/api/v3/results/${name}?limit=120&apikey=123` ); // TODO add throttle so as to not exceed 10 calls per second // Fuction that returns a Promise that resolves after given Milliseconds const timer = ms => new Promise(res => setTimeout(res, ms)) for (let i = 0; i < urlsList.length; i+=10) { getStaticProps(urlsList.slice(i-10, i)); await timer(1000); //It will make 10 calls and wait 1 seconds } const getStaticProps = async (urls) => { Promise.allSettled( urls.map((url) => fetch(url).then((resp) => resp.json()) ) ).then(console.log); };

about 4 years ago · Juan Pablo Isaza Report

0

Espero que esto ayude :)

 const urls = allNames.map( (name) => `https://example.com/api/v3/results/${name}?limit=120&apikey=123` ); // 1s === 1000ms const delay = async (ms) => new Promise((resolve) => setTimeout(resolve, ms)); const isEven = (num) => num % 2 === 0; const getStaticProps = async () => { const response = await Promise.allSettled( urls.map(async (url, index) => { if (index && isEven(index / 5)) await delay(1000); return await fetch(url).then((res) => res.json()); }) ); };
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!