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

156
Views
How to retrieve nested data in firebase -realtime database (using javascript) HTML

We are trying to retrieve data from a nested parent child relationship from realtime database from firebase using javascript (Html). Below is the code we are using and output, but the section of where there is nested data we are getting [object, Object] and undefined. We get the desired output on the console but not on the webpage.

    const db = getDatabase();
    
    var tablebody = document.getElementById('assQuestions');

    var asspool = [];


    function addassquesvalues(quescat,quesid,queslaws,lawname,statements,question){

        let trow=document.createElement('tr');
        let td1=document.createElement('td');
        let td2=document.createElement('td');
        let td3=document.createElement('td');
        let td4=document.createElement('td');
        let td5=document.createElement('td');
        let td6=document.createElement('td');

        asspool.push(quescat,question,queslaws);
        td1.innerHTML = quescat;
        td2.innerHTML = quesid;
        td3.innerHTML = queslaws;
        td4.innerHTML = lawname;
        td5.innerHTML = statements;
        td6.innerHTML = question;

        trow.appendChild(td1);
        trow.appendChild(td2);
        trow.appendChild(td3);
        trow.appendChild(td4);
        trow.appendChild(td5);
        trow.appendChild(td6);
        tablebody.appendChild(trow);

        console.log(queslaws)
    }


    function addassquesvaluestotable(questions){
        tablebody.innerHTML="";
        questions.forEach(element=>{
            addassquesvalues(element.quescat, element.quesid, element.queslaws, element.lawname, element.statements, element.question);
        })

    }

    
    function getdatarealtime(){
        const dbref=ref(db,"AssessmentQues");
        onValue(dbref,(snapshot)=>{
            var allassques = [];
            snapshot.forEach(childSnapshot => {
                allassques.push(childSnapshot.val());
            });
            addassquesvaluestotable(allassques);
        })
    }

    window.onload = getdatarealtime;

Output in form of a table

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!