I only get this output when I do doc console.log. :{"date": "2022-04-12T19:17:14.413Z", "firstPlayer": true, "gameBoard": ["null", "null", "null", "null", "null", "null", "null", "null", "null"], "roomid": "w273S", "secondPlayer": false} but when i can try console.log(doc.roomid) or anythink undefined error. How Can I parse this?
function getRoomData(room){
database()
.ref(`rooms/${room}`)
.on('value', snapshot => {
snapshot.forEach(doc => {
console.log(doc)
})
})
}
function getRoomData(room){
database()
.ref(`rooms/${room}`)
.on('value', snapshot => {
let data = snapshot.val();
console.log(data.roomid);
})
}
Try this way