Property ‘sendEmailVerification’ does not exist on type ‘Promise‘.ts(2339)

I have this error :

Property 'sendEmailVerification' does not exist on type 'Promise<User>'.ts(2339)

my code :

// Send email verfificaiton when new user sign up
  SendVerificationMail() {
    return this.afAuth.currentUser.sendEmailVerification()
    .then(() => {
      this.router.navigate(['verify-email-address']);
    })
  }

I don’t know the origin of the error and what am I missing?

Answer

You’ll need to wait until the promise resolves:

  SendVerificationMail() {
    return this.afAuth.currentUser.then((user) => {
      return user.sendEmailVerification();
    }).then(() => {
      this.router.navigate(['verify-email-address']);
    })
  }   

Leave a Reply

Your email address will not be published. Required fields are marked *