response.status 代码在使用 API 时未定义
response.status code is Undefined while using an API
在使用 API 时,我得到的是 undefined
而不是 200 或 404 之类的状态代码。
app.get('/', function(req, res){
const url = ''; //The API key
https.get(url, function(response){
console.log(response.statuscode);
});
res.send('App is running');
});
应该是:response.statusCode
const req = https.request(options, (response) => {
console.log('statusCode:', response.statusCode);
});
在使用 API 时,我得到的是 undefined
而不是 200 或 404 之类的状态代码。
app.get('/', function(req, res){
const url = ''; //The API key
https.get(url, function(response){
console.log(response.statuscode);
});
res.send('App is running');
});
应该是:response.statusCode
const req = https.request(options, (response) => {
console.log('statusCode:', response.statusCode);
});