I am having an error when I load the page the first time.
I have the following code in that component.
<router-link
:to="{
name: 'play',
params: { token: this.$route.params.token,
id: user.id }
}"
target="_blank"
>
<button class="btn btn-warning fz-btn-play">
<i class="fas fa-play"></i>
</button>
</router-link>
when page loads first-time user.id is giving error because when it loads user variable is null.
error is TypeError: Cannot read property 'id' of null
then I run created() method:
created() {
axios.get("/api/getUser").then((response) => {
this.user = response.data;
});
},
when page is fully loaded it is working fine but the error is showing in console how to remove this error.