Reputation: 53
I have a question related to SocketIO, NodeJS and javascript. I have a client, which should show information in realtime. I'm using this code to parse JSON object
socket.on('message', function(dataString){
var data=JSON.parse(dataString.replace(/'/g, '"'));
//..Extra stuff to process the data
}
However I got Uncaught SyntaxError: Unexpected end of input, everytime that the message arrives to the client.
What can I do to avoid this error?
Cheers
Upvotes: 0
Views: 339
Reputation: 161
You seem to be missing a ')', try this:
socket.on('message', function(dataString){
var data=JSON.parse(dataString.replace(/'/g, '"'));
//..Extra stuff to process the data
});
Upvotes: 1