Complete the code to send a password reset email using Firebase Authentication.
firebase.auth().[1]('user@example.com')
The sendPasswordResetEmail method sends a password reset email to the user.
Complete the code to handle the promise returned by sending a password reset email.
firebase.auth().sendPasswordResetEmail('user@example.com').[1](() => { console.log('Email sent'); })
The then method handles the successful completion of the promise.
Fix the error in the code to properly catch errors when sending a password reset email.
firebase.auth().sendPasswordResetEmail('user@example.com').then(() => { console.log('Email sent'); }).[1]((error) => { console.error(error.message); })
The catch method is used to handle errors in promises.
Fill both blanks to create a function that sends a password reset email and logs success or error.
function resetPassword(email) {
firebase.auth().[1](email).then(() => {
console.log('Reset email sent');
}).[2]((error) => {
console.error('Error:', error.message);
});
}The function uses sendPasswordResetEmail to send the email and catch to handle errors.
Fill all three blanks to create an async function that sends a password reset email and handles errors with try-catch.
async function resetPasswordAsync(email) {
try {
await firebase.auth().[1](email);
console.log([2]);
} catch (error) {
console.error([3]);
}
}The async function uses sendPasswordResetEmail with await, logs a success message, and catches errors to log the error message.