0

why I got the error: wait is only valid in async function

const sleep = async ((ms) =>  {
     new Promise(res => setTimeout(res, ms))
})

const test1 = async (() => {
    await sleep(1000)
})

await test1()

Thanks !

user3552178
  • 2,197
  • 3
  • 28
  • 53

0 Answers0