i'm using angular with firebase authentication. when i use onAuthStateChanged method to know if the user is logged in or not it does not return the user or even with angularfireAuth.currentUser when i want to retrieve the user data it's giving me this error: for example i used afAuth.currentUser.uid to use it in my query functions
Uncaught (in promise): TypeError: Cannot read property 'uid' of null
this is the code i call in my authService's Constructor:
 firebase.auth().onAuthStateChanged(firebaseUser => {
          if (firebaseUser) {
            console.log(firebaseUser.uid)
            this.user.next(firebaseUser)
            return (firebaseUser.uid)
          } else {
            return (null)
          }
    })
I think i have to do it asynchronously but i don't know how? Any Ideas?
 
     
     
    