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:



firebase structure


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.





Can you place a console.log before snapshot.forEach(function(childSnapshot) to see if the code is getting to your inner function?
– RyanNerd
Jul 1 at 7:09


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.

Popular posts from this blog

How to add background colour in existing image using Swift?

Moria Casán

How to make file upload 'Required' in Contact Form 7?