我正在使用ESRI API,并从服务器请求JSON数据,我想用此数据制作图表,因此我需要这样的数据
Request(reqUrl, reqOptions).then(function (response) {
*i do some stuff here with data which is going great *
needsForAdmins(response.data)
})
function needsForAdmins(response) {
let librariesNeed = 0
for (let i = 0; i < response.features.length; i++) {
librariesNeed += response.features[i].attributes.library
}
let data = google.visualization.arrayToDataTable([
['section', 'number', { role: 'style' }],
['library', librariesNeed , '#b7d1eb'],
]);
let options = {
bar: {
groupWidth: "80%"
},
animation: {
startup: true,
duration: 1500,
easing: "inAndOut"
},
legend: {
position: 'none'
}
};
let chart = new google.visualization.ColumnChart(
document.getElementById('needsForAdmins'));
chartdraw(data2, options);
}
因此,每次我从服务器获取数据并使其显示以下功能时:
未捕获到的TypeError:无法读取未定义的属性“功能”。
如何将响应传递给函数?