Javascript 牛津计划中未定义年龄

Javascript 牛津计划中未定义年龄,javascript,Javascript,所以我得到了一个错误,年龄是未定义的。这是牛津代码项目。我的API密钥已更新 var oxford = require('project-oxford'); client2 = new oxford.Client(//my api key); client2.face.detect({ path: '../practiceCode/cropped.jpeg', analyzesAge: true, analyzesGender: true }).then(functio

所以我得到了一个错误,年龄是未定义的。这是牛津代码项目。我的API密钥已更新

var oxford = require('project-oxford');
client2 = new oxford.Client(//my api key);

client2.face.detect({
    path: '../practiceCode/cropped.jpeg',
    analyzesAge: true,
    analyzesGender: true
}).then(function (response) {
    console.log('The age is: ' + response[0].attributes.age);
    console.log('The gender is: ' + response[0].attributes.gender);
}).catch(function (err) {
  console.log(err);
});

执行
console.log(response[0].attributes)
内的
.then()
,您将得到一个答案。添加到@Ibu的注释中,查看
console.log
输出是否包含年龄数据更好,
console.log(response)
-响应可能不是数组,但仍然显示其未定义,因此,如果我使用console.log(response)我会得到“年龄是:[object object]”如果我使用console.log(response[0].attributes)我会得到“年龄是:未定义的”,我想我仍然会遇到同样的问题“年龄是:未定义的”