简体   繁体   中英

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

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);
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM