我创建了一个函数来找出"角色"某人从那时起,我希望能够在控制台中记录用户角色。这是功能:
getUserRole() {
return this.afAuth.authState.switchMap((auth: any) => {
this.usersCollection = this.afs.collection<any>('users');
this.userDoc = this.usersCollection.doc(auth.uid);
this.user = this.userDoc.valueChanges();
return this.user.map(user => {
return user.role;
});
});
}
我尝试过console.log(user.role)
,但这似乎不起作用。有谁知道怎么做?