read a users UID from Firebase
read a users UID from Firebase
I'm trying to read in uid into a var but for some reason it does not work. My database is:

if (user) { // User is signed in!
var uid = user.uid;
var refreshToken = user.refreshToken;
firebase.database().ref().child("owners").orderByChild("uid").equalTo(uid).on('value', function (snapshot) {
snapshot.forEach(function(childSnapshot) {
var controller=childSnapshot.val().name;
console.log('controller is: ' + controller);
});
});
my console.log statement never shows to the console. Any help would be appreciated as the really has me stumped right now.
console.log
snapshot.forEach(function(childSnapshot)
1 Answer
1
try this:
firebase.database().ref().child("owners").child("Pellet_Pirate_1").child("details").orderByChild("uid").equalTo(uid).on('value', function (snapshot) {
snapshot.forEach(function(childSnapshot) {
var controller=childSnapshot.val().name;
console.log('controller is: ' + Controller);
});
});
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Can you place a
console.logbeforesnapshot.forEach(function(childSnapshot)to see if the code is getting to your inner function?– RyanNerd
Jul 1 at 7:09