I get a snapshot value that if I console.log it works but I when I return the value I get "undefined".
I tried changing variable and changing the return values and using await and async.
async function GetElements(element, place) {
firebase.database().ref().child(place).orderByChild("uid").equalTo(element).once('value', (snapshot) => {
snapshot.forEach(function(childSnapshot) {
Holder = childSnapshot.val();
});
}, (errorObject) => {
console.log("User does not exist");
document.cookie = "uid=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT";
window.location.replace("login.html");
});
return Holder;
}
async function Test() {
var bob = await GetElements("POkHi19eyZTfdeYECVpZByeVv2R2", "users/");
console.log(bob)
}
Test()
Via Active questions tagged javascript - Stack Overflow https://ift.tt/ICsoGYX
Comments
Post a Comment