I am trying to get all the results from a map with time out.
I’ve tried to use promise.all() But it didn’t succeed because of the setTimeout function.
I will be happy if someone can look oh my code and suggest how to do it right.
Thank you very much.
new Promise(async (resolve, reject) => {
  Promise.all(
    items.map(async (item, i) => {
      await setTimeout(async () => {
        return await SendMail(item);
      }, 5000 * i);
    })
  ).then((mailsRes) => {
    resolve(mailsRes);
  });
});
 
     
     
     
    