Nodejs Http Request Post Error Socket Hang Up
Hi I'm having problems to perform HTTP request on NodeJS given a larger number array of json object. The request works fine given small array of json object. However, if I try to i
Solution 1:
You can stream the request body.
If the data in buf
was in a readable stream then you can just do buf.pipe(req)
.
For example, if the current directory contains a file data.json
with the JSON you can do
var buf = fs.createReadStream(__dirname + '/data.json');
to create a ReadStream object. Then you can pipe this to you req
buf.pipe(req);
The pipe command will call req.end
once its done streaming.
Post a Comment for "Nodejs Http Request Post Error Socket Hang Up"