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.sendMessage()
Code:
const promise = query.exec();
promise.then(async (doc) => {
let count = 0;
for (const val of Object.values(doc)) {
++count;
await bot.sendMessage(msg.chat.id, ` ${count} and ${val.text}`, opts);
}
}).catch((err) => {
if (err) {
console.log(err);
}
});
Error:
[eslint] Unexpected `await` inside a loop. (no-await-in-loop)