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

193
Views
Can't access child value of my firebase database

The problem is my movies' comment values return undefined in third photo. But in console it works properly. I want to access my comments and retrieve them. How can i do this? (btnComment is my buttons id. textComment is textarea tag's id. show variable giving my movie's id. my movie's id=1)

btnComment.addEventListener('click', (e) => {
    var movieComment = document.getElementById('textComment').value;
    push(child(firebaseRef, 'Movies/' + show + '/Comments'), movieComment) {
        movieComment: movieComment
    };
});
get(child(firebaseRef, `Movies/` + show + '/Comments')).then((childSnapshot) => {
    if (childSnapshot.exists()) {
        console.log(childSnapshot.val());
    } else {
        console.log("error");
    }
})

var body2 = document.getElementById('detail2');

function AddItemsToTable2(comment) {
    const comments = `
              <td>Alan Smith</td>
              <td><i class="fa fa-star" style="color:green"></i></td>
              <td>${comment}<h6>[May 09, 2016]</h6></td>
            `;
    html = comments;
    body2.innerHTML += html;
}

function AddAllItemsToTable2(TheComments) {
    body2.innerHTML = "";
    TheComments.forEach(element => {
        AddItemsToTable2(element.movieComment);
    });
}

function getAllDataOnce2() {

    var show = qs["movieId"];
    get(child(firebaseRef, `Movies/` + show + '/Comments/')).then((childSnapshot) => {
        var comments = [];
        comments.push(childSnapshot.val());
        AddAllItemsToTable2(comments);

    });
}
window.onload = (event) => {
    getAllDataOnce2();

};

enter image description here

enter image description here

enter image description here

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!