0
People see if someone can help me.
I need to make a call on the API, but it’s a lot of data, and I want Angular to wait for that termination, At that moment I put a file but it does not wait and as the API is treating the data on the Nodejs side Angular performs a second call in the API by running over and creating two calls on the execution line. Code of my service:
buscarConsumo(dadosConsumo): Promise<any> {
return this.http.post(`${API_AZURE}/buscarconsumoperiodo`, dadosConsumo)
.toPromise()
.then((data) => data)
.catch((e) => console.log('Erro na Service', e));
}
My API takes 3 to 4 minutes to finish, I will treat this in bank in the future, more at the precise moment bring the data to the client side, tried to put timeout more unsuccessfully.
If you want an asynchronous call to occur only after the other one is over, then just put the second one inside the
then
of the first– Costamilam
Blza Guilherme, so this second call seems to me something automatic from the angular, I call the API and it keeps running, after a time the angular got no answer he sends again, I want a way not to make this second call or increase my timeout
– FernandoAntunes
Tries to return to Promise or observable and do then logic in your component.
– Eduardo Vargas
Blza @Eduardovargas? I did it and it worked
– FernandoAntunes