0
I’m using the setTimeout function in the form of Promise, following the example of the Mozilla documentation. It turns out that the callback function is running before the end of the counter, immediately after the start of the program.
base function:
function wait(time) {
return (
new Promise(resolve => setTimeout(resolve, time))
)
}
resolution (this that is giving problem):
wait(2000).then(console.log('wating...'))
using async/await works normally:
async function getWait() {
await wait(2000)
console.log('wating...')
}
getWait()