I am trying to create profile page for users.
I created login/register pages and I am using firebase auth. When I tried to fetch users data, everything works fine but if the profile page is reloaded, I can not see any data. (I need to go somewhere else first, then come back profile page, everything is ok again.)
I am using vue.js, kinda new in both technologies.
I tried to understand lifecycles (& also tried every options) but I could not solve the problem.
<template>
<div>
<h2>Profile</h2>
<h6><b>User Name:</b> {{details.name}} </h6>
<h6><b>User Email:</b> {{details.email}} </h6>
<h6><b>User photoUrl:</b> {{details.photoUrl}} </h6>
<h6><b>User uid:</b> {{details.uid}} </h6>
<h6><b>User EmailVerified:</b> {{details.emailVerified}} </h6>
</div>
</template>
<script>
import firebase from 'firebase'
export default {
data() {
return {
user: firebase.auth().currentUser,
details: {
name: '',
email: '',
photoUrl: '',
uid: '',
emailVerified: ''
}
}
},
created(){
if(this.user){
console.log('There is a user')
this.details.name = this.user.displayName,
this.details.email = this.user.email,
this.details.photoUrl = this.user.photoURL,
this.details.emailVerified = this.user.emailVerified,
this.details.uid = this.user.uid
} else {
console.log('No user')
}
},
methods: {
},
}
</script>
mountedinstead ofcreated?