3
如何獲取當前登錄的用戶密鑰。我已經試過這種方式。如何在登錄時獲取當前用戶密鑰
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'
}
})
}
});
});
}
我試圖獲取當前用戶在這部分代碼:
this.afAuth.authState.take(1).subscribe(data =>{
this.profileData = this.af.object(data.uid);
console.log(this.profileData);
})
當我控制檯日誌profileData我得到這個東西: