Как отправить несколько запросов на один api
Есть такой код:
<script>
import axios from "axios";
export default {
data() {
return {
rounds: [],
matches:[]
}
},
created() {
axios.get(`https://api.sportsdata.io/v3/csgo/scores/json/CompetitionDetails/${this.$route.params.competitionId}?key=`)
.then(response => {
response.data.Seasons.forEach(season => {
season.Rounds.forEach(round => {
if (this.$route.params.seasonId == round.SeasonId){
this.rounds.push(round.RoundId)
}
})
})
})
this.rounds.forEach(roundId => {
axios.get(`https://api.sportsdata.io/v3/csgo/scores/json/Schedule/${roundId}?key=`)
.then(response => {
this.matches.push(response.data)
})
})
},
}
</script>
Нужно вставить каждый элемент массива this.rounds в https://api.sportsdata.io/v3/csgo/scores/json/Schedule/{roundid} Почему-то массив this.matches пустой. В массиве rounds есть элементы
Источник: Stack Overflow на русском