Reputation: 137
Property 'map' does not exist on type. I am Trying to import 'rxjs' module different way but it does not work.
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
list(){
return this.http.get(endpoint)
.map(responce=>responce.json())
.catch(this.handleError)
}
Upvotes: 3
Views: 11113
Reputation: 31835
Since it is Angular 6, you're using RxJS in its 6th version.
This is the RxJS 6 way for what you want to do:
import { map } from 'rxjs/operators';
list(){
return this.http.get(endpoint)
.pipe(
map(responce=>responce.json()),
catchError(this.handleError)
)
}
In angular 6 you don't have to call .json()
because it's done implicitly so this sample is wrong and you don't need map
at all, but it's just to show you the equivalent for .map()
in RxJS 6
Upvotes: 14
Reputation: 137
Open your terminal and just command this
npm install --save rxjs-compat
or
npm install --save rxjs-compat@6
or
npm i rxjs-compat --save-dev
I home your problem will be fixed.
Upvotes: -1