Answer the question
In order to leave comments, you need to log in
How to wait for queries to complete in a loop?
I have a large database of cart accounts, I need to run it and send messages to everyone, here is the code:
users.map(async (user) => {
bot.sendMessage(user.from_id, 'hollo habr')
})
Answer the question
In order to leave comments, you need to log in
if the request is successful, delete the record from users + wrap the loop in while (users.length > 0)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question