how to put a sleep function in node js code example
Example 1: nodejs promise sleep
await new Promise(r => setTimeout(r, 2000));
Example 2: sleep in nodejs?
await sleep(1000)
function sleep(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}