Search code examples
angularjsnode.jshttpsthingworx

Making https call in nodejs


I have to make a HTTPS call in nodejs but I am unable to make it .

I am using the below code

request('https://url for the service', { json: true }, (err, res, body) => {
  if (err) { return console.log(err); }
     console.log(body.url);
    console.log(body.explanation);
});

But I am getting an error

Connection Timeout :

ip:443

Please let me know where I am going wrong


Solution

  • Set rejectUnauthorized:false while calling https request. Because request client will throws an error while doing SSL handshake.

    request('https://url for the service', { json: true, rejectUnauthorized: false }, (err, res, body) => {
      if (err) { return console.log(err); }
         console.log(body.url);
        console.log(body.explanation);
    });