繁体   English   中英

如何使用ionic和firebase获取注册用户的uid

[英]How to get the uid of a registered user with ionic and firebase

我正在尝试向Firebase注册用户,一旦注册了该用户,我想将其添加到Firestore数据库中,但是我无法访问刚刚注册的用户的uid。

registerUser(name: string, email: string, password: string): Promise<any> {
return this.afAuth.auth.createUserWithEmailAndPassword(email, password).then((newUser:any) => {
    console.log(newUser.uid)
});
}

newUser.uid未定义,如何访问此值?

谢谢

根据此处的文档-https: //firebase.google.com/docs/reference/js/firebase.auth.Auth#createUserWithEmailAndPassword

函数返回“返回firebase.Promise,其中包含非null firebase.auth.UserCredential

console.log(newUser.user.uid)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM