1

So I am still quite new to Vue.js or any reactive framework for that matter.

I have a component that I need to have update whenever a change is made. The idea is that it is taking a balance from a specific login.

<li :key="balance">Balance {{ balance }}</li>
data() {
    return {
      games: [],
      balance: '101',
      error: ''
    }
}

async created() {
    try{
      this.balance = await WalletService.getBalance();
    } catch(err){
      console.log(err.message);
    }
  }

From my own debugging, it looks like the created() function is not being called after my router.push() when the user logs in. How can I ensure that created() is called after router.push

2
  • try using mounted() instead of created()? Commented Apr 17, 2020 at 14:30
  • So when I switch from created() to mounted() I still have the same issue, but I now get an error in the console "Unchecked runtime.lastError: The message port closed before a response was received." Commented Apr 17, 2020 at 14:36

1 Answer 1

2

Remove the async keyword from created().

Although lifecycle methods can perform asynchronous code, the lifecycle itself is synchronous.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.