0

After I updated angular/cli, I got an error:

error TS2339: Property 'map' does not exist on type 'Observable<Response>'

enter image description here

I tried every possible solution from Property 'map' does not exist on type 'Observable<Response>'

but still the error exists.

FAISAL
  • 33,618
  • 10
  • 97
  • 105
Talha Zahid
  • 13
  • 1
  • 2
  • 3

3 Answers3

14

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';
FAISAL
  • 33,618
  • 10
  • 97
  • 105
  • getUsers(){ return this._http.get(this.baseUrl+'/show-users', this.options).pipe(map((response:Response)=>response.json())); } using .pipe() doest not resolve the issue. – Talha Zahid May 24 '18 at 07:46
  • `import { map } from 'rxjs/operators';` – FAISAL May 24 '18 at 07:46
2

For the latest Version of rxjs we need to install npm install rxjs-compat from terminal then declare

import 'rxjs/add/operator/map';

Avinash Ranjan
  • 180
  • 2
  • 11
0

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()));                
}
Ilthizam Imtiyas
  • 160
  • 1
  • 6
  • 17