[Vuejs]-How to set a timeout so that an await takes at least a certain amount of time?

0👍

For example, to wait for 1 second in an async function:

await new Promise(resolve => setTimeout(resolve, 1000))

You could also extract this into a more convenient utility:

function wait(seconds) {
  return new Promise(resolve => setTimeout(resolve, seconds * 1000))
}

await wait(1)

Leave a comment