I have to call an endpoint multiple times and get the responses aggregated to a single array. Below is the response from the endpoint;
{
items: [
{key1: value},
{key2: value}
]
}
Below is the code to call the endpoint multiple times;
const chunkedArray = getChunkedArray(largeArray);
const result = await Promise.all(
chunkedArray.map(async (items) => {
const response = await ....get(`http:/url/${items}`);
return response.items;
});
);
For the result I'm getting below;
[
[
{key1: value},
{key2: value}
],
[
{key3: value},
{key4: value}
]
]
What I want is an aggregated array like below;
[
{key1: value},
{key2: value},
{key3: value},
{key4: value}
]
What is the optimum way of doing that?