You are reading a single comment by @maze1980 and its replies. Click here to read the full conversation.
  • res.on('data', is triggered as soon as the first data arrives, not when all data is there. That causes the error, if you replace the line console.log(JSON.parse(data).datetime); with console.log('###'); you'll see that `res.on('data', is triggered multiple times.
    As such you're trying to parse an incomplete JSON string, and the error is normal.
    Edit: And it's pure luck that it works in node.js.

About

Avatar for maze1980 @maze1980 started