The 'map' property does not exist in type 'Observable Response'

0

I'm using version 6 of Angular and found an error when using Observable. It says that the map property does not exist in the Observable type. my code is like this.

import { Observable } from 'rxjs/Observable';
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';

         extratossaldo():Observable<Extratos[]> {
        return this.http.get('${MEAT_API}/extratos')
            .map(response => response.json());
}
    
asked by anonymous 24.05.2018 / 07:35

2 answers

2

From version 5.5 of rxjs the correct way to use operators and the following:

import { Observable } from 'rxjs/Observable';
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import { map } from 'rxjs/operators/map';
import { map } from 'rxjs/operators';  <!-- Angular 6 -->


extratossaldo():Observable<Extratos[]> {
    return this.http.get('${MEAT_API}/extratos').pipe(
        map(response => response.json()));
}
    
24.05.2018 / 11:51
0

Thanks to Eduardo Vargas. It worked, the only thing I changed was the imports of the map and the observable. I did so ... import {Observable} from 'rxjs / internal / Observable'; import {map} from 'rxjs / operators';

    
24.05.2018 / 20:10