I am push
ing on object into my ROOMS
array with .on("child_added", ....)
as below. One of the parts of that object is an array of other objects (Player
obj which has some properties like id
, name
, and so on). How do i assign to ROOMS.players
because snap.child("players").val()
does not work (EXCEPTION: Error trying to diff '[object Object]'
) snap.child("players").val()
structure looks something like this:
-rooms
-id
-name
-isRoomFull
+board
-players
-kEFvdfeff84fdfdff
-id
-name
-kEFvd4545dfjh9fvv
-id
-name
getRooms() {
this.roomsRef.on("child_added", function(snap) {
ROOMS.push({
id: snap.child("id").val(),
name: snap.child("name").val(),
players: [], //how to assign to this property
isRoomFull: snap.child("isRoomFull").val(),
board: snap.child("board").val(),
})
});