Firebase realtime database returns undefined child value.
Here is my database tree screenshot: databaseScreenShot
Here my code:
var ref = firebase.database().ref('/user/' + u_id + '/');
ref.once("value")
.then(function(snapshot)
{
log = snapshot.child("longitude").val();
console.log(log); //Prints the real value
});
console.log(log); //prints undefined value
The expected results are that it should print the actual value both outside the query and also inside the query.
But the actual results are that it prints the actual value inside the query as mentioned in comments in the code above and the prints undefined value outside the query as mentioned in the comments above.
Aucun commentaire:
Enregistrer un commentaire