• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

147
Views
I'm trying to read a field of all Documents at the same time but I'm only getting the field of first document

I'm trying to get the field items(array) of all my documents Orders, but I can only get one of my documents field at a time. I want it to show the whole Order detail as well.

Output i get Firestore database

Here is the code I have:

function receiptData() {

    document.getElementById("pro").innerHTML = "";
    firebase
        .firestore()
        .collection("orders")
        .get()
        .then((querySnapshot) => {

            querySnapshot.forEach((doc) => {

                console.log(doc.id, " => ", doc.data());

                var data = doc.id;

                for (let i = 0; i < doc.id.length; i++) {


                    let row = `<tr>
                            <td><a>${(doc.data().items[i]["productname"])}</a></td>
                            <td><a>${(doc.data().items[i]["cart_quantity"])}</a></td>
                            <td class="text-danger"> <a>${doc.data().total_amount}</a> <i class="mdi mdi-arrow-down"></i>
                            </td>
                            <td>
                                <label class="badge badge-danger"><a></a></label>
                            </td>
                            </tr>`;

                    document.getElementById("pro").innerHTML += row;
            }

        });
    });
}
about 3 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error