Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript async await for x seconds

function timeout(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}
async function sleep(fn, ...args) {
    await timeout(3000);
    return fn(...args);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #async #await #seconds
ADD COMMENT
Topic
Name
9+5 =