Answer the question
In order to leave comments, you need to log in
Why is an empty array coming from nodejs server?
Server
var players = [ uryBa10dquiRVP77AAAD: { id: 'uryBa10dquiRVP77AAAD', x: 200, y: 200 },
PPF6HbYRf3dm30w1AAAE: { id: 'PPF6HbYRf3dm30w1AAAE', x: 200, y: 200 } ];
socket.broadcast.emit('updatePlayers', players);
var players = { id: 'uryBa10dquiRVP77AAAD', x: 200, y: 200 };
socket.broadcast.emit('updatePlayers', players);
Answer the question
In order to leave comments, you need to log in
You need to decide.
Or like this (associative array):
var players = {
uryBa10dquiRVP77AAAD: { id: 'uryBa10dquiRVP77AAAD', x: 200, y: 200 },
PPF6HbYRf3dm30w1AAAE: { id: 'PPF6HbYRf3dm30w1AAAE', x: 200, y: 200 }
};
var players = [
{ id: 'uryBa10dquiRVP77AAAD', x: 200, y: 200 },
{ id: 'PPF6HbYRf3dm30w1AAAE', x: 200, y: 200 }
];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question