Encountered a scenario where I need to fetch data from an API (e.g. cars via getCars()) that returns Observables and then get additional data by car model (e.g. features via getFeatures(model)) in order to replace the features data for each car.
In relation to this, how can we incorporate a conditional operator to trigger a request for getFeatures(...) only when the model is 'porsche'?
this.getCars().pipe(
map(cars => {
...
}))
.subscribe(cars => {})
export interface Car {
id: string,
model: string,
engine: string,
details: Detail[]
}
export interface Detail {
features: string[]
...
}
If you have any insights or ideas on this matter, please feel free to share them. Your assistance would be greatly appreciated. Thank you in advance :)