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

Asked

Viewed 1,585 times

0

I am using version 6 of Angular and found an error when using Observable. It says q 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());
}
  • which version of rxjs you are using?

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()));
}

0

Thanks Eduardo Vargas. It worked, the only thing I changed was the map and observable Imports. I did so ... import { Observable } from 'rxjs/Internal/Observable'; import { map } from 'rxjs/Operators';

Browser other questions tagged

You are not signed in. Login or sign up in order to post.