This question has been asked before, but I have tried the solutions that others have gotten and they do not work for me. I list the solutions I have tried at the bottom of this question.
After trying multiple import variations in my ionic2 application, I still get the error,
Property 'map' does not exist on type 'Observable<Object>'.
when trying to use the map function from rxjs. The following is my code.
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map';
/*
Generated class for the LevelTestDataProvider provider.
See https://angular.io/guide/dependency-injection for more info on providers
and Angular DI.
*/
@Injectable()
export class LevelTestDataProvider {
constructor(public http: HttpClient) {
console.log('Hello LevelTestDataProvider Provider');
}
getRemoteData() {
this.http.get('PUT JSON URL HERE').map((res: Response) => res.json()).subscribe(data => {
console.log(data);
})
}
}
I have tried the following import statements:
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map';
import { Observable } from 'rxjs'; // causes an error
import 'rxjs/add/operator/map';
import { Observable } from 'rxjs/Observable';
import 'rxjs/Rx';
import { map } from "rxjs/operators"; // causes an error
import 'rxjs/Rx';
Additionally, I have made sure my Typescript version is up-to-date. It is currently version 2.6.2. I double-checked that my package.json file reflects this version.
UPDATE 1: My RxJS version is 5.5.2