Suppose we have an array with order numbers:
const orders = [123, 456, 789];
You need to make GET requests for the API and get information about the order by its number:
import { forkJoin } from 'rxjs'; forkJoin( // вымышленный сервис с методом service.getOrderById(123), service.getOrderById(456) ).subscribe((orders) => { // `orders` - это массив с инфо console.log(orders); });
forkJoin is an analogue of Promise.all , only Promise.all does not know how to work with streams, an array with order numbers can be of any length:
const orders = [.....]; // массив длиной 10 forkJoin( orders.map((order) => service.getOrderById(order)) ).subscribe((orders) => { console.log(orders); });