Error in sendPasswordResetEmail - Firebase

#1

I am trying to send a reset password link using firebase in ionic application…but when i do this…it shows the following error
Error Message: Object { code: “auth/internal-error”, message: "{“error”:{“errors”:[{“domain”:“glob…”, stack: “” }
The code is below

async resetPassword(user:User){     
    const reset = await this.afauth.auth.sendPasswordResetEmail(user.email)
    .then(function(reset){ 
              if(reset){ 
                  this.navCtrl.push(ResetPage);     
                           this.toast.create({  
                                 'message':"Password reset email has been sent to your mail",          
                                  duration:5000,   
                            }).present();
             }else{ 
              console.log('Error while sending Reset link email'); 
       } 
      },function(error){  
         console.log("Error Message:",error);
       });
  }

it directly gets into else part…but when i tried to print the user email id its printing the user email id in console…like i did

let email = user.email;
console.log(email);

Anyhelp thanks…

#2

Don’t ever type the word “function” inside of one. Always use arrow functions or lambdas.

#3

just now i edited my post…see the post.now i bolded the text which the actual error was…:slight_smile:

#4

You’re using async/await with non-lexical functions containing this, which is a breeding ground for nondeterministic bugs.

I recommend you ditch async//await, and instead handle the Promise returned by af as a Promise, with resolve and reject arrow functions.