вы находитесь на правильном пути:
Promise.all([
getInitialData,
// you need to spread this one as it is an array of promises:
...ids.map(id => getStudentName(id),
]);
Вот демоверсия:
все асинхронные c функции заменены обещаниями, которые разрешаются в случайное время
const fnPromise = () => new Promise((resolve, reject) =>
setTimeout(() => resolve(), Math.round(Math.random() * 1000))
);
let i = 0;
async function getInitialData() {
await fnPromise();
return i++;
}
async function getStudentName() {
await fnPromise();
return i++;
}
const ids = [1, 2, 3, 4, 5, 6];
async function init() {
$("#console").html('Please wait...');
const allResolved = await Promise.all([
getInitialData(),
...ids.map(() => getStudentName()),
]);
// console.log(JSON.stringify(allResolved, null, 2))
$("#console").html(`[${allResolved.join(', ')}]`)
}
init()
body {
background: #333;
color: #fff;
font-size:2rem;
}