我仍然是Promises的新手,并且认为我抓住了他们,但这个问题让我陷入困境。我的代码:
return axios.post('./getParks.php')
.then((daysGames)=> {
console.log(daysGames.data);
let dailyData = daysGames.data;
Object.keys(dailyData).map((day)=> {
运行控制台后记录:
Object {1: Object, 2: Object..}
TypeError: Cannot read property 'data' of undefined
我也尝试过以下操作导致同样的错误:
let dailyParks = axios.post('./getParks.php');
return dailyParks
.then((daysGames)=> {
console.log(daysGames.data);
let dailyData = daysGames.data;
Object.keys(dailyData).map((day)=> {
答案 0 :(得分:0)
我已经修好了,但我不能完全确定它为何有效。如果有人能够启发我的理由,那将非常感激
return axios.post('./getParks.php')
.then((daysGames)=> {
console.log(daysGames.data);
let dailyData = daysGames;
Object.keys(dailyData.data).map((day)=> {