Reputation: 433
I am trying to query Firebase records in my HTML page, but I haven't found any luck by now.
I am using JavaScript and here is the current code that I have. Is there a proper way to output the records? I understand it is a JSON formatted file.
var ref = new Firebase("https://ngong-hills.firebaseio.com/Bookings");
ref.orderByChild("Bookings").on("child_added", function(snapshot) {
console.log(snapshot.key());
document.write(snapshot.key());
});
Is there anything i am missing??
Upvotes: 1
Views: 915
Reputation: 588
Looks like you are using very old tutorial, as
This code works for me
<script src="https://www.gstatic.com/firebasejs/3.6.1/firebase.js"></script>
<script>
var config = {
apiKey: "***",
authDomain: "crackling-fire-7458.firebaseapp.com",
databaseURL: "https://crackling-fire-7458.firebaseio.com"
}
var app = firebase.initializeApp(config);
var ref = app.database().ref('/');
ref.on('value', function(snapshot) {
console.log(snapshot.val());
});
</script>
Upvotes: 1