How Should I await for bot.sendMessage()
inside of loop?
Maybe I Need await Promise.all
But I Don\'t Know How Should I add to bot.sendM
Performing await
inside loops can be avoided once iterations doesn't have dependency in most cases, that's why eslint
is warning it here
You can rewrite your code as:
const promise = query.exec();
promise.then(async (doc) => {
await Promise.all(Object.values(doc).map((val, idx) => bot.sendMessage(msg.chat.id, `