1
您好我正在嘗試按計劃進行http調用。計劃中的第一次出現工作正常,從第二次發生我得到空物體和未定義。遞歸模式下的nodejs http請求
var https = require('https');
var schedule = require('node-schedule');
var rule = new schedule.RecurrenceRule();
rule.second = 10;
schedule.scheduleJob(rule, function(){
var options = {
host: 'google.co.uk',
method: 'get',
path: '/'
};
var req = https.request(options, function(res) {
// some code
console.log('Expity date is ' + res.socket.getPeerCertificate(true).valid_to);
});
req.end();
});
輸出如下,爲什麼按時間表運行時不工作?
Expity date is Oct 5 13:16:00 2016 GMT
Expity date is undefined