Simple question I hope you good people can help me with.
I'm using Firebase and I can display my firebase data on the page using:
var dbRef = firebase.database().ref().child('jumbotron/header');
dbRef.on('value', snap => container.innerText = snap.val());
But when I try to: console.log(dbRef)
It displays as an object. I think this is because the reference is a URL. How can I console.log or print my firebase data as a string and eventually place it on my page using vanilla javascript. I can't find the solution in the FB documentation and there aren't any tutorials on the Google FB.
Any help is much appreciated. Thanks, All
Simple question I hope you good people can help me with.
I'm using Firebase and I can display my firebase data on the page using:
var dbRef = firebase.database().ref().child('jumbotron/header');
dbRef.on('value', snap => container.innerText = snap.val());
But when I try to: console.log(dbRef)
It displays as an object. I think this is because the reference is a URL. How can I console.log or print my firebase data as a string and eventually place it on my page using vanilla javascript. I can't find the solution in the FB documentation and there aren't any tutorials on the Google FB.
Any help is much appreciated. Thanks, All
Share Improve this question edited Jul 14, 2016 at 14:53 Frank van Puffelen 600k85 gold badges890 silver badges860 bronze badges asked Jul 14, 2016 at 4:49 Moe-JoeMoe-Joe 1,0303 gold badges15 silver badges30 bronze badges1 Answer
Reset to default 9As the name implies dbRef
is a reference to the data, it is not the data itself.
When you attach a listener to the reference with on()
, you will get a snapshot of the data at that location. You can get the value from this snapshot and print it:
var dbRef = firebase.database().ref().child('jumbotron/header');
dbRef.on('value', snapshot => {
console.log(snapshot.val());
});