I encountered the following error message:
Argument of type 'OperatorFunction<APISearch[], APISearch[]>' is not assignable to >parameter of type 'OperatorFunction<Object, APISearch[]>'.
The 'Object' type is only assignable to a few other types. Perhaps you meant to use the 'any' type instead?
search.servic.ts
public getTracksAndArtists(term: string): Observable<APISearch[]> {
const searchUrl: string = `search?q=${ term }&type=track%2Cartist`;
return this.globalService.getQuery(searchUrl).pipe(
map((res: APISearch[]) => {
if (!res) {
throw new Error('Value expected!');
} else {
console.log('res:', res);
return res;
}
}),
catchError((err) => {
throw new Error(err.message);
}));
}
getQuery function
public getQuery(query: string) {
// define common url
const url: string = `https://api.spotify.com/v1/${query}`;
// define header to specify token
const headers = new HttpHeaders({
'Authorization': 'Bearer BQAr2XNaHkRgSxk-lWKIUEjHTPT1pG7qj696yYQgdpTLKSuVL9oMGcENth0yynhRilrfN_FjFxtGd3f9poE'
});
// execute request
return this.http.get(url, { headers });
}
APISearch interface
export interface APISearch {
artists: Artists;
tracks: Tracks;
}
Any assistance would be greatly appreciated. I did attempt to use any, but it seems like I might be implementing it improperly.