How do i get the current user key who has log in. I have tried this way.
openMapPage()
{
var ref = firebase.database().ref("request");
ref.once("value").then((snapshot) => { // <------ Here!
var a = snapshot.exists(); // true
var c = snapshot.hasChild("reqdetails"); // true
var d = snapshot.child('reqdetails').exists();
var requestsKey = snapshot.key;
var requestsValue = snapshot.val();
this.afAuth.authState.take(1).subscribe(data =>{
this.profileData = this.af.object(data.uid);
console.log(this.profileData);
})
snapshot.forEach((childSnapshot) => { // <------ And here!
var requestKey = childSnapshot.key;
var requestValue = childSnapshot.val();
var reqdetails = requestValue.reqdetails;
if (reqdetails) {
this.data = requestKey;
console.log(this.data);
//this.arr.push(requestKey);
//console.log(this.arr);
this.getRequest = this.angFire.list('request', {
query: {
orderByChild: 'reqdetails',
startAt: 'reqdetails'
}
})
}
});
});
}
I have tried getting the current user at this part of the code:
this.afAuth.authState.take(1).subscribe(data =>{
this.profileData = this.af.object(data.uid);
console.log(this.profileData);
})
When i console log for profileData i am getting this thing:
