Let's assume I have a REST server with two possible GET requests.
One like this: /allItems
and another one: /{itemId}/picture
.
The first returns all stored items on my server as an array (only once), in which each one has an Id.
For each of them i would like to request their respective picture and match it with them.
Something like this:
this.http.get('/allItems').map(itemArray => {
itemArray.forEach(item => {
this.http.get('/' + item.id + '/picture')
.subscribe(pic => item.pic = pic)
return itemArray
}
})
At the end i want to return one Observable which emits the item-array with their respective pictures mapped, so other functions can access the complete data.
Might be worth mentioning: I'm using Angular/Typescript.