nodejs应用程序如何请求我的另一个https服务器?

下面是nodejs应用程序来请求我的另一个https服务器

var https = require('https'); jsonObject = JSON.stringify({"arg1":"4","arg2":"True"}); // prepare the header var postheaders = { 'Content-Type' : 'application/json', 'Content-Length' : Buffer.byteLength(jsonObject, 'utf8') }; // the post options var optionspost = { host : 'https://www.example.com/', path : '/my/path/?arg1=4&arg2=True', method : 'POST', headers : postheaders }; var reqPost = https.request(optionspost, function(res) { console.log("statusCode: ", res.statusCode); res.on('data', function(d) { console.info('POST result:\n'); process.stdout.write(d); console.info('\n\nPOST completed'); }); }); reqPost.write(jsonObject); reqPost.end(); reqPost.on('error', function(e) { console.error(e); }); 

我总是得到错误以下任何人都可以说我错了什么地方

{[Error:getaddrinfo ENOTFOUND https://www.example.com/] code:'ENOTFOUND',errno:'ENOTFOUND',syscall:'getaddrinfo',hostname:' https ://www.example.com/'}

 // the post options var optionspost = { host : 'www.example.com', path : '/my/path/?arg1=4&arg2=True', method : 'POST', headers : postheader } 

主机属性需要是完全限定的域名。 删除https://和结尾的斜杠,它应该工作。