I am attempting to create a service with Angular that returns a particular data set.
The shape of the object returned from the api is this:
{
status: string,
totalResults: number,
results: [array of objects]
}
so on my service, I want to return an observable of the array of results when status is "ok" and totalResults > 0 (meaning I don't want to return an empty array).
my service is looking like this but I'm struggling with the syntax of iif and want to combine it with pluck.
getData(): Observable<result[]> {
this.http.get<APIResponseObj>(
this.url
).pipe(
mergeMap(v =>
iif(
() => v.status && v.totalResults,
this.results$(v)
)
)
)
}