Javascript 创建用户身份验证后,我无法将数据保存到数据库
在firebase上创建用户身份验证后,我无法将数据保存到数据库,控制台上出现以下错误:TypeError:firebase.auth。。。。CurrentUser为空。在创建身份验证后,代码似乎无法读取用户的uid 守则:Javascript 创建用户身份验证后,我无法将数据保存到数据库,javascript,firebase,firebase-realtime-database,firebase-authentication,Javascript,Firebase,Firebase Realtime Database,Firebase Authentication,在firebase上创建用户身份验证后,我无法将数据保存到数据库,控制台上出现以下错误:TypeError:firebase.auth。。。。CurrentUser为空。在创建身份验证后,代码似乎无法读取用户的uid 守则: 需要更改哪些内容,以便代码可以读取用户的uid并将数据保存在数据库中?在写入数据库之前,您不会等待新用户创建过程完成。返回在工作完成时解析的承诺。它将为您提供一个工作对象 firebase.auth().createUserWithEmailAndPassword(emai
需要更改哪些内容,以便代码可以读取用户的uid并将数据保存在数据库中?在写入数据库之前,您不会等待新用户创建过程完成。返回在工作完成时解析的承诺。它将为您提供一个工作对象
firebase.auth().createUserWithEmailAndPassword(emailInput.value, passwordInput.value)
.then(userCredential => {
// write the database here
})
.catch(error => {
// there was an error creating the user
})
这回答了你的问题吗?哇,我把这部分代码放进去了,现在它工作得很好,谢谢!!
firebase.auth().createUserWithEmailAndPassword(emailInput.value, passwordInput.value)
.then(userCredential => {
// write the database here
})
.catch(error => {
// there was an error creating the user
})