Reputation: 17184
I have api which returns list of photos object, which I want to iterate using subscribe().. not all at once, but one by one..
http.get('photos.json')
.map(res => res.json());
Which functions (map, flatmap...) can I use to convert response into multiple array, so when using subscribe, it will iterate one by one.. and not all response at once.
json example file
Upvotes: 3
Views: 3110
Reputation: 41254
You can use flatMap
:
http.get('photos.json')
.map(res => res.json())
.flatMap((array, index) => array)
.filter(photo => 600 <= photo.height)
.subscribe(photo => console.log(photo))
Upvotes: 2