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)
}
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)
}
Share
Improve this question
edited Apr 16, 2021 at 13:54
Guerric P
31.8k6 gold badges58 silver badges105 bronze badges
asked Sep 23, 2018 at 16:32
JakiJaki
1371 gold badge3 silver badges10 bronze badges
1
-
Btw you should also migrate to
HttpClient
. – Martin Adámek Commented Sep 23, 2018 at 17:13
2 Answers
Reset to default 14Since 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
Open your terminal and just mand this
npm install --save rxjs-pat
or
npm install --save rxjs-pat@6
or
npm i rxjs-pat --save-dev
I home your problem will be fixed.