Ionic error trying to diff array


#1

hi,

I’m having a problem with my API.

Please see my code

  tabs:any=[];
  matches : any;

  getMatches(){
  
    this.http.get('https://api.wh.geniussports.com/v1/basketball/competitions/19816/matcheslive?ak=eebd8ae256142ac3fd24bd2003d28782&limit=100')
    .map(res=> res.json())
    .subscribe(data => {
      this.matches = data.response.data;
      console.log(this.matches);
      for (let i = 0; i < this.matches.length; i++) { 
       let shit =  this.matches[i].matchTime;
       this.tabs = shit.concat();
       console.log(this.tabs);
    }
     
    }, err => {
      console.log(err);
    
    });
  }


Whenever I got same data from array it says error trying to diff.


#2
 matches : any;
 response : any = []

  getMatches(){
  
    this.response = this.http.get('https://api.wh.geniussports.com/v1/basketball/competitions/19816/matcheslive?ak=eebd8ae256142ac3fd24bd2003d28782&limit=100')
    this.response.subscribe(data => {
      this.matches = data.response.data;
      console.log(this.matches);
      for (let i = 0; i < this.matches.length; i++) { 
       let shit =  this.matches[i].matchTime;
       this.tabs = shit.concat();
       console.log(this.tabs);
    }
     
    }, err => {
      console.log(err);
    
    });
  }


#3

It’s says “cannot read undefined ‘data’”


#4

I removed this line


#5

after i used your code. It says cannot read property ‘data’ undefined.


#6

this code i tried & then send you.

send your code after change


#7
  tabs:any;
  response : any = [];
  matches : any;

 constructor(public http: Http,public navCtrl: NavController ,platform: Platform) {
    this.getMatches();
  }

 getMatches(){
  
    this.response = this.http.get('https://api.wh.geniussports.com/v1/basketball/competitions/19816/matcheslive?ak=eebd8ae256142ac3fd24bd2003d28782&limit=100')
    this.response.subscribe(data => {
      this.matches = data.response.data;
      console.log(this.matches);
      for (let i = 0; i < this.matches.length; i++) { 
       let shit =  this.matches[i].matchTime;
       this.tabs = shit.concat();
       console.log(this.tabs);
    }
     
    }, err => {
      console.log(err);
    
    });
  }

output says: cannot read property ‘data’ of undefined


#8

i used https://angular.io/api/common/http for api call.