How to use promise function inside JavaScript array map?

To use promise function inside JavaScript array map, we use the Promise.all method.

For instance, we write

const mappedArray = await Promise.all(
  array.map((p) => {
    return getPromise(p).then((i) => i.Item);
  })
);

to call Promise.all with an array of promises returned by map to invoke all the promises in the returned array in parallel.

And we use await to get an array all the results from the promises in the array.