How to get the uid of a registered user with ionic and firebase
How to get the uid of a registered user with ionic and firebase
I'm trying to register a user with firebase, once the user is registered, I would like to add them to the firestore database but I can't access the uid of the user that just registered.
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 is undefined, how do I access this value?
Thanks
1 Answer
1
according to the documentation here - https://firebase.google.com/docs/reference/js/firebase.auth.Auth#createUserWithEmailAndPassword
the function returns "returns firebase.Promise containing non-null firebase.auth.UserCredential"
console.log(newUser.user.uid)
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.