i have this simple code as a service
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { map } from 'rxjs/operators';
@Injectable({
providedIn: 'root'
})
export class SpotifyService {
constructor(private http: HttpClient) {
}
getQuery(query: string) {
const cabecera: HttpHeaders = new HttpHeaders({
'Authorization': 'Bearer BQDWZC2Y_iSV3rfmAhv-QxDpmhhJbbmgCnspy7HpIZPX5CbJ74D4Xl4aOyXLUL4smF2gZ_V3wiSXLxdLFPY'
});
const url = 'https://api.spotify.com/v1/' + query;
return this.http.get(url, { cabecera });
}
getNewReleases() {
return this.getQuery('browse/new-releases').pipe(map( data => data['albums'].items));
}
}
but i'm getting this error and i dont understand why.
Argument of type '{ cabecera: HttpHeaders; }' is not assignable to parameter of type '{ headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: Ht...'. Object literal may only specify known properties, and 'cabecera' does not exist in type '{ headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: Ht...'.