node.jsアプリケーションで、https api呼び出しを行いたいとします。 https
モジュールで試していますが、動作していませんが、request
モジュールを試してみてください。node.jsでHttps要求が機能しない
私はこの
problem with request: getaddrinfo ENOTFOUND myserver/platform-api/v1
myserver/platform-api/v1:80
これは、それが最初のもので動作しない理由を私は理解することはできません
request("https://myserver/platform-api/v1/projects?access_token=38472", function(error, response, body) {
if (error) return console.log(error);
//console.log(error);
//console.log(response);
console.log(body);
});
の作品を入手
var options = {
host : 'myserver/platform-api/v1',
port : 80,
path : '/projects?access_token=38472',
method : 'GET',
headers : {
'Accept' : 'application/json'
}
};
var req = https.request(options, function(res) {
res.on('data', function(chunk) {
console.log(chunk);
});
});
req.on('error', function(e) {
console.log(e);
console.log('problem with request:', e.message);
});
req.end();
に動作しません。なぜ誰が知っていますか?
おかげ
オプションをパラメータとして渡す代わりに、options.pathを渡すことができますか? –