By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

https://jsfiddle.net/5p6g2wxL/

Steps to reproduce

Here is the sample code, which is a vuex test module sample :
import Vue from 'vue'
class UnitTest {
get timestamp() {
return this._timestamp();

async _timestamp() {
// make sure each timestamp is unique
let promise = await Vue.nextTick()
console.log('timestamp ready : ', promise)
return new Date().getTime().toString()
let test1 = new UnitTest()
console.log('timestamp : ', test1.timestamp)

What is expected?

According to the docs, calling Vue.nextTick() or this.$nextTick() returns a promise.
https://vuejs.org/v2/api/#vm-nextTick

What is actually happening?

My code shows that Vue.nextTick() doesn't return a promise

  • Is there a problem calling Vue.nextTick() in a custom vuex module?
  • Is there a problem with my async / await syntax?
    I followed this related mozilla tutorial : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function
  • It does return a promise, there may be something wrong in your project. Closing as the repro is invalid.

    Please, next time consider using the forum , the Discord server or StackOverflow for questions first. But feel free to come back and open an issue if it turns out to be a bug 🙂

    About the line : console.log('timestamp ready : ', promise)
    In Chrome console, this shows : timestamp ready : undefined
    My jsfiddle sample doesn't handle console prints, but anyway it looks like a bug

    Thanks, this version still returns a promise even though await is supposed to return the resolved value
    async _timestamp() {
    // make sure each timestamp is unique
    await Vue.nextTick()
    return await new Promise((resolve) => { resolve(new Date().getTime().toString()) })

    A function with the async signature will always return a Promise. A function invoked with await will always resolve the promise and return the resolved value. That is the standard interaction between Promises and async/await.

    Your original Fiddle adheres to this. Vue.nextTick() returns a Promise, of which you are await ing. The await ed value is undefined , which is also correct.

    If you are in an environment with async / await capability, you almost never need Promises in your code. If you want to pass around a Promise though, just remove the await keyword from an async function call and you'll get its Promise.

    BTW you can and should do this: