Firebase v3 createUserWithEmailAndPassword .then Promise

后端 未结 4 1937
醉话见心
醉话见心 2020-12-09 08:56

Firebase v3 Reference Guide indicates that createUserWithEmailAndPassword(email, password) returns firebase.Promise containing non-null fireb

4条回答
  •  余生分开走
    2020-12-09 09:48

    Just for future stumbles upon it, an await-async example:

    export const doCreateUserWithEmailAndPassword = async (pEmail, pPassword) => {
        try {
            const authResult = await app.auth().createUserWithEmailAndPassword(pEmail, pPassword);
             usersRef.doc(authResult.user.uid)
                .set({
                    email: pEmail,
                    created: firebase.firestore.FieldValue.serverTimestamp(),
                  });
        }
        catch(error){
            console.log(error);
        }
    }
    

提交回复
热议问题