Angular newbie needs help!

hey there!

thank you for reading :slight_smile:

so I’m making a pokedex using angular. 

I want to get data first from this API:
the JSON looks like this:


for that, I made 2 separate classes -just to get things organized- for the shape of the data

export class pokemonEndpoint{
    count: number;
    next: string;
    previous: boolean; 
    result: myData[];
export class myData{
    name: string;
    url: string;

I made a service that gets the data:

export class ApiService {
  //pokes: pokemonEndpoint;
  private url='' ;
  constructor( private http: HttpClient){}

  getPokemonNames(): Observable<pokemonEndpoint>{
    return this.http.get<pokemonEndpoint>(this.url);

  (everything is imported appropriately)

Also, I made a component to display that data, in the TS file got the data from the service like that:

export class PokemonComponent implements OnInit {
  myList: pokemonEndpoint;

  constructor(public endpoint: ApiService) { }

  ngOnInit() {

    this.endpoint.getPokemonNames().subscribe(myList => this.myList=myList);

to test that it works I tried to display what is supposed to be fetched:

    {{ }}
    {{ myList.result[0].name }}

well, the app crashes, there’s an error that says that result is undefined. are my classes wrong? The data an array of objects inside one.
if I remove 

{{ myList.result[0].name }}

the app displays the count and the URL correctly but there are still errors that say:
“Cannot read property ‘count’ of undefined”

how did it display it if it’s not defined I’m confused

Please help, I’ve tried to understand what’s going on but to no avail

ok so I found the first mistake, it was stupid, lol

but I still get that they are undefined. that is still confusing.

You’re going to have to show us a little more info. Like the full source file containing the <div> tags you showed in your first post. You might use a gist for that.

The “undefined” suggests you’ve not set up “myList” in such a way as Angular can “see” it.