Map doesn't exist on Observable<Object> with angular 6.0.0 and rxjs 6.1.0

前端 未结 7 710
情歌与酒
情歌与酒 2020-12-29 07:46

Hi I\'m trying to follow a tutorial on angular but the tutorial was made in September. I believe the person used angular-cli 1.3.2. I\'m not sure which version of rxjs he wa

相关标签:
7条回答
  • 2020-12-29 08:12

    You have to change to pipe syntax:

    import { Http  } from '@angular/http';
    import { Injectable } from '@angular/core';
    import {map, catchError} from "rxjs/operators";
    
    import { Observable, throwError } from 'rxjs';
    
    list():Observable<any>{
        return this.http.get(this.url)
        .pipe(
          map((e:Response)=> e.json()),
          catchError((e:Response)=> throwError(e))
        );
      }
    
    0 讨论(0)
提交回复
热议问题