From nodejs server side I have written the below code
socketIOobj.to(clientID).emit('send-prev-conversation-data',{ prevConversation: JSON.stringify(finalOutputArray) });
Here, if I do console.log(finalOutputArray), I got the below output
[ [ convId: 11,
no: 1,
time: 2016-12-27T17:36:19.000Z,
subjectline: 'message005' ],
[ convId: 10,
no: 2,
time: 2016-12-26T18:02:17.000Z,
subjectline: 'fdf' ],
[ convId: 4,
no: 2,
time: 2016-12-25T09:46:12.000Z,
subjectline: 'cds' ],
[ convId: 3,
no: 4,
time: 2016-12-25T09:33:39.000Z,
subjectline: 'gg2' ] ]
But, when I try to receive the finalOutputArray array value in client side using below code
socket.on( 'send-prev-conversation-data', function( data ) {
console.log(data.prevConversation);
var aa=JSON.parse(data.prevConversation);
console.log(aa);
console.log(aa[0]);
socket.removeAllListeners('send-prev-conversation-data');
});
I got the output as:
[[],[],[],[]]
Array [ Array[0], Array[0], Array[0], Array[0] ]
Array [ ]
Here, my question is that, how I get exact array what I have created in nodejs like:
[ [ convId: 11,
no: 1,
time: 2016-12-27T17:36:19.000Z,
subjectline: 'message005' ],
[ convId: 10,
no: 2,
time: 2016-12-26T18:02:17.000Z,
subjectline: 'fdf' ],
[ convId: 4,
no: 2,
time: 2016-12-25T09:46:12.000Z,
subjectline: 'cds' ],
[ convId: 3,
no: 4,
time: 2016-12-25T09:33:39.000Z,
subjectline: 'gg2' ] ]
in client side, so that I can use it to show the data in client browser.