0

I have and array of Http post in angular

peticionesI3.push( ...dataArrayI3.map( data => this.httpService.doPost(url, data, '')) );

and call like this

return this.httpService.doPost(url, data1, '')
        .pipe(
            switchMap( r => combineLatest( peticionesI2 )),
            switchMap( r => combineLatest( peticionesI3 )),
        )

This array, peticionesI3, is too bigger and exceeded the maximum calls allowed. How can I divide in blocks of 50, and called each block after the previous one is finished?

Thanks in advance

  • See if this helps: https://stackoverflow.com/a/62872189/6513921. Increase/decrease the `bufferCount` argument to adjust the max no. of parallel calls. – ruth Jul 21 '23 at 06:45

1 Answers1

0

combineLatest will subscribe to all Observable concurrently. Instead you can use concat (or eventually merge with concurrency parameter) to susbcribe to reqeust one by one.

Then to collect all responses into a single array chain it with toArray().

import { concat, toArray } from 'rxjs';

...

switchMap(r => concat(...peticionesI3).pipe(toArray())),
martin
  • 93,354
  • 25
  • 191
  • 226