Please describe the question in detail and share your code, configuration, and other relevant info.
I work API as a beggiener i have and err of push;
ERROR TypeError: Cannot read properties of undefined (reading ‘push’)
here is my code ;
movies.page.html:
<ion-title>Top Trend Movies</ion-title>
<ion-item button *ngFor="let item of movies">
<ion-label>{{item.title}}
<p>{{item.release_date | date : 'y'}}</p>
</ion-label>
<ion-badge slot="end" > {{item.vote_average}}
</ion-badge>
</ion-item>
movies.page.ts
import { Component, OnInit } from ‘@angular/core’;
import { LoadingController } from ‘@ionic/angular’;
import { MovieService } from ‘src/app/services/movie.service’;
@Component({
selector: ‘app-movies’,
templateUrl: ‘./movies.page.html’,
styleUrls: [’./movies.page.scss’],
})
export class MoviesPage implements OnInit {
movies: any;
currentPage: 1;
constructor(
private movieService: MovieService,
private loadCtrl: LoadingController
) {}
ngOnInit() {
this.loadMovies();
}
async loadMovies() {
const loading = await this.loadCtrl.create({
message: 'Loading..',
spinner: 'bubbles',
});
await loading.present();
this.movieService.getTopRatedMovies(this.currentPage).subscribe((res) => {
loading.dismiss();
// this.movies = [this.movies, res.results];
this.movies.push(res.results);
console.log(res);
});
}
}
plz anyone help me this to overcome this problem…