Using .getTokenSilently() in created | Auth0 - VueJs

I am trying to verify details from a user in the created() method in vuejs. This allows me to determine what component to show the user.

However, using

async created() {
    // Get the access token from the auth wrapper
    const token = await this.$auth.getTokenSilently();

gives me the error of "[Vue warn]: Error in created hook (Promise/async): “TypeError: Cannot read property ‘getTokenSilently’ of null” and “vue.runtime.esm.js?2b0e:1888 TypeError: Cannot read property ‘getTokenSilently’ of null”

It works fine when on a button, but surely i need to determine this before the component is loaded?

Any ideas?

Any ideas Guys? still stuck…

Hi, @Plainnn

There was a previous Community topic addressing use of this.$auth which I think may be the answer you are looking for. The short explanation is that $auth is only applied to Vue components; used elsewhere, it will return null. Please take a look over the solution in the earlier thread for further details and let us know if that does not resolve the issue for you.

You can find that topic here: The prototype this.$auth in Vue main.js always null