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

89
Views
Disparador de múltiples apis sin usar settimeout

He llamado a la función de actualización de datos cada 4 segundos hasta que la longitud de los registros sea 0.

Dentro de la actualización de datos this.callAPI(); es desencadenar llamada api.

Configuré el tiempo de espera manual durante 4 segundos para llamar a la función a callapi.

En lugar de tiempo de espera, cómo llamar a la API inmediatamente después de que se completó la API anterior.

 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 answers
Answer question

0

Su problema está en tener estado. Haga que la función callapi no tenga estado y pase todos los parámetros necesarios para que pueda llamarla cualquier cantidad de veces y no confíe en la llamada o estado anterior

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!