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.
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);
});
}
It’s says “cannot read undefined ‘data’”
after i used your code. It says cannot read property ‘data’ undefined.
this code i tried & then send you.
send your code after change
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