getWriterWithFavBooks(): Observable<any> {
return this.http.get(this.writerUrl, {responseType: 'json'});
} //if response type is JSON then using responseType: 'json' is optional
Now in our component subscribe to instance of Observable for actual hit of request to server and get response.
getWriterWithFavBooks() {
this.writerService.getWriterWithFavBooks().subscribe(
data => {
this.favBooks = data['books'];
}
);
}