skip to Main Content

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.

2

Answers


  1. 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;
    }
    Login or Signup to reply.
  2. since firebase 9 :

    auth =getAuth();
    createUserWithEmailAndPassword(auth,email,password)
            .then(userCredential=>userCredential.user)
            .then(user=>{sendEmailVerification(user)})
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search