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

95
Vistas
Multiple apis trigger without using settimeout

I have calling dataUpdate function every 4 second until records length to 0.

Inside the dataUpdate this.callAPI(); is trigger api call.

I set manual timeout for 4 seconds to call the function to callapi.

Instead of timeout ,how to call the api immediately after previous api completed.

 dataUpdate =()=> { 
     var arrayList = this.arrayList; 
     if(arrayList.length > 0)
     { 
         var inputData = {
             ...inputData,
             data:{
                 ...inputData.data,first:'',second:'' 
             }
          }; 
            var first = arrayList[0].first;
            var second = arrayList[0].second; 
            inputData.data.first = first;
            inputData.data.second = second;  
            this.setState({ inputData:inputData });  
            this.callAPI(); 
            arrayList.shift();
            this.arrayList = arrayList; 
            
                if(arrayList.length !== 0){  
                    setTimeout(() => { 
                         this.dataUpdate();
                    }, 4000); 
                } 
                
                if(arrayList.length === 0){   
                    setTimeout(() => {  
                        this.props.callMessage(this.totalCount);
                    }, 1000);    
                }
                 
       } 
  }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Your problem is in having state. Make callapi function stateless and pass all needed parameters so you can call it any amount of times and do not rely on previous call or state

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