Skip to content

Retrieve specific data from firebase Javascript

New to javascript here. I’m trying to pull a specific set of data from my firebase database and print it to my website but I am struggling to do so. The problem is it prints out every field in the database.

As you can see in this image, I would like the fields for just that particular ID printed out onto my website and not the fields for all the different ID’s [1]:

Here is what I have so far

var db = firebase.firestore();

const list_div = document.querySelector("#list_div");

db.collection("catalogue").get().then((querySnapshot) => {
querySnapshot.forEach((doc) => {

   list_div.innerHTML += "<h3>" + + "</h3><p> Price: " + +  "</p></div> Quantity" + +



The below will get data for id which you want:

    function getDataById(anyId) {
      .then(function(doc) {
         if (doc.exits) {
            var desc =,
            var name =,
            var price =
            var qty =