There are incoming objects, such as:
Object {pos: "test2" , tar : "1"} Object {pos: "test3" , tar : "2"} Object {pos: "test4" , tar : "3"} Object {pos: "test5" , tar : "4"} It is necessary to unite in one line, what would be test2, test3, test4, test5 How to do it right?
client:
socket.on('infos', function (data) { console.log(data); }); server:
tsRoom.send("clientlist", function(err, response){ if(err){ console.log(err) } else { response.forEach(function(response) { socket.emit('infos', { pos: response.names, tar: response.uid }); }); } }); Incoming response data to the loop:
[ { uid: 1, names: 'test2', { uid: 2, names: 'test3', { uid: 3, names: 'test4', { uid: 4, names: 'test5' } ]