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();
});
}