API data:
{"photos":[{"id":1,"title":"photo_1_title"}]}
My code has a photos variable and a method called getPhotos()
photos: any;
getPhotos() {
this.photoService.getPhotos()
.subscribe(
photos => this.photos = photos
// here, instead of doing this, I want to add the array of photos I get back to this.photos using Object.assign however it is giving me the said error
)
}
For the next call, I get back
{"photos":[{"id":2,"title":"photo_2_title"}]}
Can someone help me with why jsfiddle.net/ca46hLw9 doesn't work?