0

I have tried researching on the use of async and await but i dont understand. what is the use of it in layman terms? and where can we use it?

like in this example, what is async or the function is trying to do.

Example of async and await

   resetPassword(email: string) {
this.angularFire.sendPasswordResetEmail(email).then(async () => {
  let alert = await this.alertCtrl.create({
    header: 'Reset Password',
    message: 'Password reset email sent! Check your inbox.',
    buttons: [{
      text: "OK",
      handler: () => {
        this.navCtrl.pop();
      }
    }]
  })
  await alert.present();
}).catch(async () => {
  let alert = await this.alertCtrl.create({
    header: 'Alert',
    message: "Email or account does not exist. Please try again with a valid email or account!",
    buttons: [{
      text: "OK",
      handler: () => { }
    }]
  })
  await alert.present();
});

}

  • Welcome to SO please read [ask] and take the [tour]. Also do not post code as images but rather as text in the question. You may want to read the [Markdown help](https://stackoverflow.com/editing-help#code) to see how you can format your code. I recommend using the code-fences `~~~` for block code. – Ackdari Sep 08 '20 at 13:34
  • Does this answer your question? [Asynchronous vs synchronous execution, what does it really mean?](https://stackoverflow.com/questions/748175/asynchronous-vs-synchronous-execution-what-does-it-really-mean) – Lionel Rowe Sep 08 '20 at 13:43
  • This is a JavaScript question, not something to Ionic or any framework. Check [Making asynchronous programming easier with async await](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Async_await) in MDN – Panagiotis Kanavos Sep 08 '20 at 13:47

0 Answers0