JSON.parse before the request is completed is leading to parse errors
Opened this issue · 2 comments
nitdrive commented
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').
Johnmiller111 commented
I'm just trying to figure all this out I don't have much help. My name is John Miller
Johnmiller111 commented
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').