Avatar ·

Erro http.get(...).map is not a function no Angular e TypeScript

Olá a todos! Comecei a estudar Angular e TypeScript, estou tentando fazer uma simples requisição HTTP GET para uma API. Instalei o Angular via CLI, criei um serviço e estou tentando obter dados. Estou usando HttpClient, mas ao chamar o método get e tentar aplicar o operador map do RxJS, recebo o erro: "http.get(...).map is not a function in [null]". Aqui está meu código: ```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() ); } } ``` E no componente: ```typescript i