Angular (2+): http.post with promise

Discussão em 'Angular' iniciado por Zvi Vered, Março 27, 2025.

  1. Zvi Vered

    Zvi Vered Guest

    I'm using the following code to send multiple HTTP posts with promise. All requests are inserted into an array:

    async SendPostRequest (id : number)
    {
    var body = this.postRequest.Serialize();
    //Push all requests into array
    this.requestArray.push (
    this.http.post (TGT_IP,body,{responseType: 'arraybuffer'}).toPromise ());
    }


    In my case array contains ~500 elements. And then I call to:

    await Promise.all(this.requestArray);


    It works. But after each http post I want also to update progress bar.
    Is it wise to insert also the progress bar update into this array ?

    Thank you, Zvika

    Continue reading...

Compartilhe esta Página