function isDisplayNameTaken(name) {
firebase
.database()
.ref()
.child("users")
.orderByChild("username")
.equalTo(name)
.once("value")
.then((snapshot) => {
return snapshot.exists();
});
}
I've been trying to check if a username is already in the database before registering a user, but the return does not work, nor does anything inside function(snapshot) change other global variables to go around it.
if(isDisplayNameTaken($userDisplayNameField.val())) {
numberOfChecksPassed += 1
}
This is the condition that does not pass through. I've done my research and been trying to solve the problem for the last 5 hours. Thanks in advance