admin管理员组文章数量:1356709
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());
});
本文标签: javascriptGoogle Firebase I want to console log my firebase dataStack Overflow
版权声明:本文标题:javascript - Google Firebase I want to console log my firebase data - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743989832a2571931.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论