Using Firebase, Firebase.auth().currentuser Is A Null Value Even Though It Is Being Logged
I created a query that is in a service.TS file that shows an items 'state' that is based on a logged in user's UID: getLists(): FirebaseListObservable { firebase.auth()
Solution 1:
onAuthStateChanged() is asynchronous, so when you have the user uid
in its callback, then only perform your operation, like this:
getLists(): FirebaseListObservable<any> {
var self = this;
firebase.auth().onAuthStateChanged(function(user) {
if (user) {
// User is signed in.
var userID = user.uid;
return self.db.list('/foods', {
query: {
orderByChild: 'state/' + userID + '/state',
equalTo: 'listed'
}
});
}
});
}
Post a Comment for "Using Firebase, Firebase.auth().currentuser Is A Null Value Even Though It Is Being Logged"