Reputation: 1
I'm pretty new to Firebase and noSQL as a whole, and I am having trouble pulling out all the JSON from the database. I've done the firecast tutorials so I know about pulling out specific values after referencing the database, but that's not what I want. I have a created a basic datatable that populates fields based off of JSON, so I want to pull all the database JSON out of firebase programmatically and do so. When I click export JSON, on my firebase database I get what I would need, but how can I pull that using the API? Below I tried referencing all children and setting it to a pre tag, but nothing shows up:
const ref = firebase.database().ref().child();
ref.on('value', snap => {
const yo = document.getElementById('test');
yo.innerText = JSON.stringify(snap.val());
});
edit* The below answer is actually correct, I had some errors in my datatable code that was keep the js from even working in the first place
Upvotes: 0
Views: 146
Reputation: 339
Get rid of .child() would be my first bet. Call .on directly on .ref()
Upvotes: 1