Hello in my code I am trying to check if a username is taken. The code goes into the if statement and prints the console.log "username exists" but it won't return true and always returns false.
get(child(ref(db), "users/")).then((snapshot) => {
if (snapshot.exists()) {
const users = snapshot.val();
for (const user in users) {
if (users[user].username == username) {
console.warn("username exists");
return true;
}
}
}
});
return false;
};