我有一个异步/等待函数调用,它在 Firebase 中对用户进行身份验证,然后我希望它采用新创建的 uid 并创建一个具有相同 id 的新文档,代码如下:
try{
const currentUser = await auth.createUserWithEmailAndPassword(email, pass)
await fdb.collection('users').doc(currentUser.user.uid).set({
Forname: fname,
Surname: sname,
Liked: [],
})
dispatch({type:'USER_REG', payload: currentUser})
} catch(err){
dispatch({type: 'ERROR', payload: 'Signin failed.'})
console.error(err);
}
第一部分工作正常,因为它向身份验证添加了一个新用户,但第二个异步没有完成,try 中的调度也没有完成。
我也没有收到任何错误,所以我不确定我哪里出错了。任何帮助,将不胜感激。