簡體   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