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,719
  • 8
  • 40
  • 67

0 Answers0