The Movie Database

#1

Hey all,

i have one Problem. I want to get Movie Information from The Movie Database Api

with this provider I want to get Data:

  getData() {
    return new Promise(resolve => {
      this.http.get('https://api.themoviedb.org/3/movie/550?api_key=KEY')
        .subscribe(data => {
          resolve(data);
        }, err => {
          console.log(err);
        });
    });
  }

in my home.ts the code looks like:

  ionViewDidLoad() {
    this.smdData.getData()
      .then((response) => {
        if (response) {
          this.movieData = response;
          console.log(response);
        }
      });
  }
this.movieData  = any;

So if I want to loop in home.html with ngFor I get this Error:

Cannot find a differ supporting object ‘[object Object]’ of type ‘object’. NgFor only supports binding to Iterables such as Arrays.

Okay that means ngFor can only work with Arrays, but how can I do my JSON Data from API to Array? Please Help

#2

Try changing movieData to array before you get the data.

this.movieData = [];

Or just declare it as an array

public movieData: any = [];