У меня есть небольшая проблема, и я не знаю, откуда она взялась.
Я использую API и с машинописью я получаю данные от 1 игрока в очереди
this.http.get("https://soccer.sportmonks.com/api/v2.0/teams/"+ this.teamid +"?api_token=9f2m43uMDPMzrQGeE8Kv9PmHQLRdu60VrTK6oWXllRvJoVIkr35s&include=latest:limit(10|1).lineup,latest.lineup,latest.localTeam,latest.visitorTeam ")
.subscribe(result => {
this.lineup = result.json();
this.lineup = Array.of(this.lineup);
console.log(this.lineup);
for(let i = 0; i < this.lineup['0']['data'].latest['data'].length; i++){
let fix = this.lineup['0']['data'].latest['data'][i];
this.fix = this.lineup['0']['data'].latest['data'];
console.log("fix",this.fix);
let lined = this.fix[i].lineup['data'][i];
this.lined = this.fix[i].lineup['data'];
this.lined = this.lined.filter(lined => lined.player_id === 580 && lined.stats.length != 0);
this.cards = this.lined[0].stats;
console.log("lined",this.cards);
}
Нопроблема, журнал консоли дает мне:
{shots: {…}, goals: {…}, fouls: {…}, cards: {…}, passing: {…}, …}
cards: {yellowcards: 0, redcards: 0}
fouls: {drawn: 1, committed: 1}
goals: {scored: 1, conceded: 0}
other: {assists: 0, offsides: 0, saves: 0, pen_scored: 0, pen_missed: 0, …}
passing: {total_crosses: 0, crosses_accuracy: 0, passes: 34, passes_accuracy: 87}
shots: {shots_total: 11, shots_on_goal: 3}
__proto__: Object
There is all Information what I need but I have this error :
Cannot read property 'stats' of undefined
This is api result, if i delete .stats at this.cards = this.lined[0].stats;
additional_position: null
fixture_id: 10420139
formation_position: 11
number: 7
player_id: 580
player_name: "Cristiano Ronaldo"
position: "F"
posx: null
posy: null
stats: {shots: {…}, goals: {…}, fouls: {…}, cards: {…}, passing: {…}, …}
team_id: 625
__proto__: Object
Я не знаю, почему это дало мне ошибку Любое решение?Спасибо