I am trying to call an API from angular but facing an issue. Here is my code.
My Code :
import { Injectable } from "@angular/core";
import { Http } from "@angular/http";
import "rxjs/add/operator/map";
// import 'rxjs/add/observable/of';
@Injectable({
providedIn: "root"
})
export class DataService {
constructor(public http: Http) {
console.log("data service connected");
}
getPosts() {
return this.http
.get("https://jsonplaceholder.typicode.com/posts")
.map(res => res.json());
}
}
I am facing an error saying "ts property 'map' does not exist on type 'observable response '"