Ketul-Patel/Uber-API-Node-Starter-Kit

JSON.parse before the request is completed is leading to parse errors

Opened this issue · 2 comments

Since JSON.parse is being used before the request is completed, it is leading to parse errors, because the data is sent as chunks (strings). A fix would be to add the JSON.parse in res.on('end') instead of res.on('data'), after appending all the chunks in the res.on('data').

I'm just trying to figure all this out I don't have much help. My name is John Miller

Since JSON.parse is being used before the request is completed, it is leading to parse errors, because the data is sent as chunks (strings). A fix would be to add the JSON.parse in res.on('end') instead of res.on('data'), after appending all the chunks in the res.on('data').