我正在使用 auth 创建一个新用户,该用户正在工作,然后使用新创建的 uid 创建一个具有相同内容的新文档。
const currentUser = await auth.createUserWithEmailAndPassword(email, pass);
console.log('user registered')
await setDoc(doc(db, "users", currentUser.user.uid),{
forname: "Peter",
surname: "Parker"
})
console.log('user profile added')
dispatch({type:'USER_REG', payload: currentUser});
当我收到控制台日志时,reg 进程会毫无问题地启动,然后程序只是等待,就像 setDoc 正在运行但从未完成,我不知道为什么。
任何帮助表示赞赏。
Try:
import { getAuth, signInWithEmailAndPassword } from "firebase/auth";
const auth = getAuth();
await auth.createUserWithEmailAndPassword(auth, email, pass).then(async(userRec)=>{
const user = userRec.user;
await await setDoc(doc(db, "users", user.uid),{
forname: "Peter",
surname: "Parker"
}).catch((error)=>{
console.log(error);
});
}).catch((error)=>{
console.log(error);
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)