我在遍历Ides时遇到问题,然后将结果推到上面的数组,它抛出此错误:“请求失败,状态码为404” 但是,如果我删除了循环,则无法正常工作
export default class GetPlayersPerMatch {
constructor(numPlayers) {
this.numPlayers = numPlayers;
this.allPlayersMatchesArr = [];
}
async getResultsPerMatch() {
try {
const proxy = 'http://cors-anywhere.herokuapp.com/'
for (let i = 0; i < 500; i++) {
const resPerMatch = await axios(`${proxy}https://fantasy.premierleague.com/api/element-summary/${i}/`)
this.playerData = resPerMatch.data
console.log(this.playerData)
this.allPlayersMatchesArr.push(this.playerData)
}
console.log(this.allPlayersMatchesArr)
} catch (error) {
console.log(error)
}
}
}