Reputation: 91
i'm trying to create an app using firebase. here my code:
const user = await createUserWithEmailAndPassword(auth, email, password)
await user.user.sendEmailVerification()
user is initializing in firebase authentication but this is happening :
TypeError: user.user.sendEmailVerification is not a function.
Upvotes: 1
Views: 468
Reputation: 26
since firebase 9 :
auth =getAuth();
createUserWithEmailAndPassword(auth,email,password)
.then(userCredential=>userCredential.user)
.then(user=>{sendEmailVerification(user)})
Upvotes: 1
Reputation: 124
You can use async-await
syntax with try-catch
this way :
try {
const { user } = await auth().createUserWithEmailAndPassword(email, password);
await user.sendEmailVerification();
return user;
} catch(e) {
return e;
}
Upvotes: 0