While developing angular application many times we came across a situation when we need to call multiple APIs parallelly and on completion of all APIs there is some task to be performed.

To handle this situation we can make use of forkJoin from RXJS library.

Below code demonstrates calling multiple APIs parallelly.

 

 import { forkJoin, Subscription } from 'rxjs';


 forkJoin([
        this.service.GetData1(),
  		this.service.GetData2(),
  		this.service.GetData3()
      ]).subscribe((result) => {
        let response1=result[0];
        let response2=result[1];
        let response3=result[2];
       });