Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/372.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 创建用户身份验证后,我无法将数据保存到数据库_Javascript_Firebase_Firebase Realtime Database_Firebase Authentication - Fatal编程技术网

Javascript 创建用户身份验证后,我无法将数据保存到数据库

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

在firebase上创建用户身份验证后,我无法将数据保存到数据库,控制台上出现以下错误:TypeError:firebase.auth。。。。CurrentUser为空。在创建身份验证后,代码似乎无法读取用户的uid

守则:


需要更改哪些内容,以便代码可以读取用户的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
})