My Node.js
code to make https POST request is,
var req = https.request(options, function(res) {
var data = '';
res.on('data', function(chunk) {
data += chunk;
});
res.on('end', function() {
var response = JSON.parse(data);
callback(null, response);
});
}).on('error', function(err) {
callback(err);
});
req.write(JSON.stringify(requestObj));
req.end();
I want to know what are the different possible errors I can get. For example, when my target server is not up, I am getting the following error,
{
[Error: connect ECONNREFUSED 127.0 .0 .1: 3000]
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 3000
}
Here the error code is ECONNREFUSED
. What are the possible error scenarios and codes for them? Is there a documentation which covers these?
The list of errors can be found in the node.js documentation in the Errors section.