In my service I execute an http call and return the response as Observable
doQuery ( query: String ) : Observable<any> {
return this.http.request(queryURL) ;
}
And in a component I subscribe
this.service
.doQuery(this.query)
.subscribe((res: any) => {
console.log ("Res");
console.log(res);
});
Doing this actually works; I can see in the console the dump of a Response object
My problem came when I want to return from the service the response alread mapped as json.
I trying to do tyhis
return this.http.request(queryURL).map((res: any) => res.json());
But at runtime I got an obscure javascript error (this is coming from Zone.js to be precise)
Error: Permission denied to access property "rejection"
I've already tried to change the return type from Observable<any> to Observable<any[]>, as seen on a book, but without success.
UPDATE :
Actually I resolved adding into the service file this
import 'rxjs/Rx';
What am I doing wrong? Why is this import needed ? Isn't a way to import Rxjs' map operator?