我有一个Javascript函数可从网站获取状态代码,我需要返回var statusCode,但此返回未定义
var request = require('request');
var statusCode;
function getStatusCode(url){
request(url, function (error, response, body) {
var statusCode = response.statusCode;
});
}
console.log(getStatusCode('http://www.google.com'));