0

I have the code for interface

export interface Books {
  artists: any;
  tracks: any;
}

And I m using this interface in service for getting search results.

getBook(keyword): Observable<Books>{
   let headers = new Headers();
   this.createAuthorizationHeader(headers);
    return this._http.get('https://api.spotify.com/v1/search?q=' + keyword + '&type=track,artist', {
    headers: headers
   })
  .map((response: Response) => <Books> response.json());
}

After getting results I want to show this in the component

getBooks(value) {
  this._search.getBook(value)
  .subscribe(
  res => {
    this.books = res;
    this.artists = Object.assign({}, res.artists);
    console.log(this.artists);
  },
  error => { this.errMessage = <any>error }
  );
}

The response looks like

{
 href: "https://api.spotify.com/v1/search?query=muse&type=artist&market=US&offset=0&limit=20",
 items: [list of objects],
 limit: 20,
 total: 159,
}

In console.log(this.artists) I am getting the above object but when I am trying to access its items in console.log(this.artists.items); it gives me this error.

Property 'items' does not exist on type 'Object'

Any idea whats I am missing ???

eko
  • 39,722
  • 10
  • 72
  • 98
Ahmer Khan
  • 747
  • 1
  • 10
  • 31

0 Answers0