Below is my service.ts
. I have added map
and catch separately. Still getting property does not exist with observable<response>
import { Injectable } from '@angular/core';
import { Http, Response, Headers, RequestOptions } from '@angular/http';
import { Observable } from 'rxjs/Observable'; // for handling service response - like promise
import { DashboardModel } from '../model/dashboard.model'
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';// Import RxJs required methods
@Injectable()
export class AppService {
constructor(private http: Http) { }
// private instance variable to hold base url
private baseUrl = 'https://www.google.co.in';
// Fetch all existing comments
getDetails(): Observable<DashboardModel[]> {
// ...using get request
return this.http.get(this.baseUrl)
// ...and calling .json() on the response to return data
.map((res: Response) => res.json())
//...errors if any
.catch((error: any) => Observable.throw(error.json().error || 'Server error'));
}
}
edit : i have seen solutions where to add map, catch etc to be imported separately. Even then, i am getting same error.