Skip to content

Instantly share code, notes, and snippets.

@abcdeepakr
Last active July 14, 2022 13:46
Show Gist options
  • Save abcdeepakr/b2d14773fe63dccfe7b0b1656ce89af9 to your computer and use it in GitHub Desktop.
Save abcdeepakr/b2d14773fe63dccfe7b0b1656ce89af9 to your computer and use it in GitHub Desktop.
delay for loop
const timer = ms => new Promise(res => setTimeout(res, ms))
async function load ()
{
for (var i = 0; i < 100; i++) {
// write the logic here, make api calls or anything
await timer(550); // will go into the next one after 550ms
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment