Before, I was using storage to pass UID from login page to any page. Then I found, firebase.auth().currentUser.uid to get the user ID from anywhere. But, it gives me an error Cannot read property. When I login, it works perfectly but then I refresh it throws that error. I have already check solution in from other posts but still couldn't understand. And everytime, I did
console.log(firebase.auth().currentUser.uid)
it gives me value but here it it throws an error.
async ngOnInit() {
this.afStore.collection('Students').doc(firebase.auth().currentUser.uid).valueChanges().subscribe(data=>{
this.firebaseData = data
},error => {
console.log(error);
});
}