Avatar ·

Error http.get(...).map is not a function in Angular and TypeScript

Hello everyone! I started learning Angular and TypeScript, trying to make a simple HTTP GET request to an API. I installed Angular via CLI, created a service and trying to get data. I'm using HttpClient, but when calling the get method and trying to apply the map operator from RxJS, I get the error: "http.get(...).map is not a function in [null]". Here is my code: ```typescript import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; @Injectable({ providedIn: 'root' }) export class DataService { private apiUrl = 'https://jsonplaceholder.typicode.com/posts'; constructor(private http: HttpClient) { } getPosts() { return this.http.get(this.apiUrl).map( (response: Response) => response.json() ); } } ``` And in the component: ```typescript i