I want it so when I click my signUp() that I also create a database filled in with empty spaces but it does not seem to work. I'm not sure if this is something to do with javascript or with firebase.
These are the scripts I have:
<script src="https://www.gstatic.com/firebasejs/8.2.9/firebase-app.js"></script> <script src="https://www.gstatic.com/firebasejs/8.2.9/firebase-auth.js"></script> <script src="https://www.gstatic.com/firebasejs/8.2.9/firebase-database.js"></script> <script src = "app.js"></script> This is the code:
const auth = firebase.auth(); var userV, nameV, ageV, genV; let userB; function signUp(){ const email = document.getElementById("email"); const password = document.getElementById("password"); const promise = auth.createUserWithEmailAndPassword(email.value, password.value); alert("Signed Up" + email.value) insert(); promise.catch(e => alert(e.message)); } auth.onAuthStateChanged(function(user) { if (user) { var email = user.email; email = email.replaceAll(/\./g, "dot"); email = email.replaceAll(/@/g,"at"); userB = email; alert("Active User " + email) } else { alert("No Active User") } }) function Ready(){ nameV = document.getElementById('nameBox').value; ageV = document.getElementById('age').value; genV = document.getElementById('gender').value; userV = document.getElementById('username').value; } function insert(){ Ready(); firebase.database().ref('users/' + userB).set({ Username: userV, NameOfStudent: nameV, Age: ageV, Gender: genV, }); } https://stackoverflow.com/questions/66524176/insert-is-not-happening-when-i-press-signup March 08, 2021 at 12:07PM
没有评论:
发表评论