Hi everyone,
I’m learning to develop with Ionic V2 and I have a problem : in my JS file I do a HTTP Request and the data is saved into a variable. When I display the variable in the console there is no problem the correct object is displayed but when I want to display an attributes of the object I have this error “Error: Uncaught (in promise): EXCEPTION: TypeError: Cannot read property ‘name’ of undefined in [{{game.name}} in GamePage@10:34]”
My JS function :
constructor(nav, http){
this.nav = nav;
this.http = http;
this.game = null;
this.http.get('http://fr.geekg.dev/Games/view/2.json').map(res => res.json()).subscribe(data => {
this.game = data;
console.log(this.game);
});
}
and the object :
{
"id": 2,
"name": "Fallout 4",
"serie": "FAL",
"releaseDate": "10 Novembre 2015",
"editor": "Bethesda",
"developer": "Bethesda"
}
PS : sorry for the English I’m French ^^