Hello how to return correct value

hi i coded lately a bit and was having a problem if i have this function

  getUser(){
    firebase.auth().onAuthStateChanged(function(user) {
    if (user) {
     
      
      // User is signed in.
    } else {
      
      // No user is signed in.
    }
  })
  
   }

so how do i get the user object down to function foot
here`

    firebase.auth().onAuthStateChanged(function(user) {
    if (user) {
     
      
      // User is signed in.
    } else {
      
      // No user is signed in.
    }
  }) ===>> return user
  
   }``
 getUser(){
    firebase.auth().onAuthStateChanged(function(user) {
    if (user) {
     console.log(user.email)==> erk@erk.com
      
      // User is signed in.
    } else {
      
      // No user is signed in.
    }
  })
  console.log(user)==> user is undefined
   }

i know its odd question but function only knows what user is in the call back brackets
how to transfer the user object to outer scope best way?

ye i cant figure it out dawson, but I keep trying its function for seeing if user is logged in / user object in firebase my favourite =)

Randell I have another question that is I wonder like this im trying to code a boolean in an promise chain but typescript js doesnt allow it how can I go about it? the code i want to add is in the result promise. {{ this.olga=true}}


olga:bollean=false;
login(user, pass){
  
  this.apple11.logIn(user,pass).then(res=>console.log(res.user),{{this.olga=true}}).catch(err=>this.olgo.push(err.code))

 
}