Here are the functions I am working with:
getNetworkByName(prefix: string): Observable<Network[]> {
return this.http.get<Network[]>(this.Url + '/networks/search?name-prefix=' + prefix)
.catch(handleError); }
and
getNetwork(id: number): Observable<Network> {
return this.http.get<Network>(this.Url + '/networks/' + id)
.catch(handleError); }
I am trying to create a new function called
getNetworkByNameAndId(prefix: string | number): observable<network[]>
that combines the results from the previous two functions. I attempted to use the merge operator but encountered issues due to different types.
Is there an efficient way to solve this without directly subscribing to the functions? This needs to be resolved on the frontend. Sometimes my network name can include special characters like "&" and also, internally, a network Id might be represented as just "1". I want the search to be based on both the name and the id. My attempt looked like this:
return this.getNetworkByName(prefix.toString()).pipe(merge(this.getNetwork(parseInt(prefix,10)));
This resulted in an error stating:
Type 'Observable<Network | Network[]>' is not assignable to type 'Observable<Network[]>'.
Thank you for your help!