Hello I have an API call getItems() that return data like this :
[
{
name: 'item1',
materials: [
1,
2,
3,
],
},
{
name: 'item2',
materials: [
2,
3,
6,
],
}
...
]
And another API call getMaterial(id) that return the data of a material like this :
{
name: 'mat1',
img: '/img.jpg'
}
What I'm try to achieve is to get all the items data with the materials data. I manage to have all the observable call for materials but I don't know what to do after.
That's what I've done so far :
public getAllItemsData(): Observable<any> {
return getItems().pipe(
map((list: items[]) => {
return list.map(item => {
const allMat = item.materials.map(m => getMaterial(m))
return forkJoin(allMat).pipe(
map(data => {
return {
...item,
materials: data
}
})
)
})
}),
);
}
But it's not working. Thank for the help.