Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

241
Vistas
How to properly request a server on loop?

I have an array of cities. A pretty big array. For every city in the array I need to make 2 requests to my server - 1 request to get the current weather for the city, and another 1 to get today news. For each of those 2 requests there is a special API endpoint. How do I get all the neccessary information properly? I mean:

  1. don't make too many requests per second
  2. the final result should store information in the same order as the cities are stored in the array
  3. if some of the requests are failed, don't stop requesting for the other cities (not like in Promise.all)
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can use Promise.allSettled() and then use a timeout to wait for a certain period of time and redo the same. Make sure to use also a request timeout (so when a server is not responding for a long time, you may want to abort).

Here is an example:

const myFunc = async () => {
  await Promise.allSettled([ ... ]);
  setTimeout(myFunc, 1000);
};
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda