To call an asynchronous function within map with JavaScript, we use the for-of loop.
For instance, we write
const promises = teachers.map(async (m) => {
return await request.get("...");
});
for (let val of promises) {
//....
}
to call teachers.map with a callback to return an array of promises.
Then we use the for-of loop to loop through each promise in the promises array and run them.