Issue
I am getting the following error in vscode:
Property 'uid' does not exist on type 'Promise'.ts(2339)
I'm also getting the same error with updateProfile:
Property 'updateProfile' does not exist on type 'Promise'.
Code:
export class SignupPage implements OnInit {
email: string;
pwd: string;
username: string;
constructor(public fs: AngularFirestore, public af: AngularFireAuth, public nav: NavController) { }
signup() {
this.af.createUserWithEmailAndPassword(this.email, this.pwd).then(() => {
localStorage.setItem('usesrid', this.af.currentUser.uid);
this.af.currentUser.updateProfile({
displayName: this.username,
photoURL: ''
}).then(() => {
this.nav.navigateRoot('/tabs')
}).catch(err => {
alert(err.message)
})
}).catch(err => {
alert(err.message)
})
}
}
I'm new to Typescript so I'm not really sure what the cause of this error could be.
Thanks in advance.
Solution
It seems your currentUser is a promise, so you need to use either await or then to get the actual user:
this.af.currentUser.then((user) => {
user.updateProfile({
...
Answered By - Frank van Puffelen
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.