Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

125
Views
Creating Divs Automaticly With forEach - That Contain Data From Firestore

I'm trying to get a list of data from Firestore to automatically create and nest themselves in divs (one for each topic) I feel like Im close but I don't know what I'm doing wrong...

Here is my code

const querySnapshot = await getDocs(collection(db, "vhf", '1', 'week1'));
    querySnapshot.forEach((doc) => {
    // doc.data() is never undefined for query doc snapshots
    //console.log(doc.id, " => ", doc.data());
    });

    querySnapshot.forEach(function(topics){
        // console.log('Topics From Function: ', topics.data().topic)
        
            let html = ''
            const weekData = topics.data();
            const li = `
            <li>
            <div class="topicRungDiv">${weekData.topic}</div>
            </li>
            `;
        html += li
        });

Could someone please help me get this working? I have patched this together from a tutorial and there are no errors with the code... But I don't understand the function of the let html = '' and the html += li

I also dont understand how to tell the code where to put the new <div> tags as id like them to be put into a specific div container.

Any help, amendments or feedback would be greatly appreciated

about 4 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 Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!