I am trying to explore a little more of TMDB API and got confused with the way I should access the data coming from one object which is inside another. The URL I linked contains the API I am calling. It has a bunch of objects for each language type containing the watch providers for a certain movie. I am properly calling this API by passing the movie ID I wish to get the said data from, but it either returns undefined or a message error on console claiming the ngFor can not loop inside an object.
My service:
listProviders(movieId: number){
return this.coreApi.get(`${endpoints.listMovies}/${movieId}/watch/providers`)
}
The component.ts:
watchProviders: any | undefined
ngOnInit():void {
setTimeout(() => {
this.route.params.subscribe(params =>{
this.listProviders(params["id"])
})
}, 1000);
}
listProviders(movieId: number){
this.moviesService.listProviders(movieId).subscribe((res) => this.watchProviders = res['results'])
}
How I am passing the data on the HTML:
<span *ngFor="let caProvider of watchProviders.CA">{{ caProvider.link }}</span>
(Scenario with the said console error)
I would appreciate any help and tips to achieve the solution. Thanks in advance!