一个简单的问题:我想将简单的数字添加到一个数组中,稍后我想将其与另一个数组进行比较。但是我无法访问更新数组的内容。
这是我的代码:
checkForUpdates(curr_dataset) {
var current = curr_dataset;
var update = [];
//put in array
axios.get('http://localhost:3030/disruptions/', {
params: {
DisruptionCategory: 0
}
})
.then(response => {
console.log("push " + response.data.data.length)
update.push(response.data.data.length);
})
.catch((error) => {
console.log(error.data);
});
axios.get('http://localhost:3030/disruptions/', {
params: {
DisruptionCategory: 1
}
})
.then(response => {
console.log("push " + response.data.data.length)
update.push(response.data.data.length);
})
.catch((error) => {
console.log(error.data);
});
axios.get('http://localhost:3030/disruptions/', {
params: {
DisruptionCategory: 2
}
})
.then(response => {
console.log("push " + response.data.data.length)
update.push(response.data.data.length);
})
.catch((error) => {
console.log(error.data);
});
axios.get('http://localhost:3030/disruptions/', {
params: {
DisruptionCategory: 3
}
})
.then(response => {
console.log("push " + response.data.data.length)
update.push(response.data.data.length);
})
.catch((error) => {
console.log(error.data);
});
console.log(update[0]); //HERE I GET "undefined"
}
要继续比较我的更新数组和当前数组的内容,我需要确保我得到了正确的值......
任何人的想法?
慕标琳琳
相关分类