Most of the examples I found online shows how to use the async pipe with either an array or an array of objects as a response from a URL API call.
The situation is that sometimes you are not gonna get an array objects but you'll get an object that contains a mix of objects and arrays inside. and you will still want to use | async inside your html. like this one
In the following Stackblitz , I added [data]="remoteData | async", and my table wont show any data. getting the following error message:
Error: InvalidPipeArgument: '[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Needless to say, if I take it off the data will show.
Obviously, I know my method works for an array as a response, in this case the response is an object. I know you are suppose to use Observables (behaviorSubject) to make this work, but having a hard time trying to get it right.
So, can I keep the async pipe? even tough the response is an object or do it need to subscribe and unsubscribe manually?
What I've tried so far: line 18 inside my service
this.listSource = apiCall;
return this.listSource;
but I get a linting error saying:
'Observable' is missing the following properties from type 'BehaviorSubject': _value, value, getValue, next, and 9 more.