问题
After I updated angular/cli, I got an error:
error TS2339: Property 'map' does not exist on type 'Observable<Response>'
I tried every possible solution from Property 'map' does not exist on type 'Observable<Response>'
but still the error exists.
回答1:
Its easy to post an answer when you provide your code instead of a screenshot. Anyhow, you have to pipe
it:
getUsers() {
return this._http.get(this.baseUrl+'/show-users', this.options)
.pipe(
map((response:Response)=>response.json())
);
Remember to import map
like this:
import { map } from 'rxjs/operators';
回答2:
For the latest Version of rxjs we need to install npm install rxjs-compat from terminal then declare
import 'rxjs/add/operator/map';
回答3:
You can find a solution by using pipe. Here are the steps...
First import map
import {map} from 'rxjs/operators';
Modify your getuser() and other all functions by using pipe
getUser(){
this._http.get(this.baseUrl+'/show-users', this.options).pipe(map((response:Response)=>response.json()));
}
来源:https://stackoverflow.com/questions/50503366/error-property-map-does-not-exist-on-type-observable