0
Node.jsを使用してHTTPS URLからXMLデータセットにアクセスしようとしています。 HTTP URLを使用した別のデータセットで同じコードを使用しましたが、うまくいきました。Node.jsを使用してhttps URLにアクセスしようとしています
これを調べたところ、https://www.npmjs.com/package/ssl-root-casですが、どうすればいいのか分かりません。
ここに私が使用しているコードがあります。
var parseString = require('xml2js').parseString;
var https = require('https');
function xmlToJson(url, callback) {
var req = https.get(url, function(res) {
var xml = '';
res.on('data', function(chunk) {
xml += chunk;
});
res.on('error', function(e) {
callback(e, null);
});
res.on('timeout', function(e) {
callback(e, null);
});
res.on('end', function() {
parseString(xml, function(err, result) {
callback(null, result);
});
});
});
}
var urlTrain = "https://data.dublinked.ie/cgi-bin/rtpi/realtimebusinformation?stopid=7602&format=xml";
xmlToJson(urlTrain, function(err, data) {
if (err) {
return console.err(err);
}
else{
console.log(data);
console.log(data.busstopinformation);
console.log(data.busstopinformation.results);
console.log(data.busstopinformation.results.result[0]);
console.log(data.busstopinformation.results.result[0].shortname);
}
})
これはコマンドラインで表示されるエラーです。 enter image description here
ご協力いただければ幸いです。