sajad torkamani

Here’s a handy little function that you can use to simulate a delay:

export async function sleep(milliseconds) {
  return new Promise((resolve) => setTimeout(resolve, milliseconds))
}

You can use it like so:

class AuthController {
  async register() {
    await sleep(3000)
    // do something
  }
}

Tagged: JavaScript

Leave a comment

Your email address will not be published. Required fields are marked *