错误:类型“可观察"上不存在属性“地图"

错误:类型“可观察

问题描述:

更新angular/cli后,出现错误:

After I updated angular/cli, I got an error:

error TS2339: Property 'map' does not exist on type 'Observable<Response>'

我尝试了类型'Observable< Response>'上不存在属性'map'

但是错误仍然存​​在.

but still the error exists.

在提供代码而不是屏幕截图时,很容易发布答案. 无论如何,您必须pipe:

Its easy to post an answer when you provide your code instead of a screenshot. Anyhow, you have to pipe it:

getUsers() {
    return this._http.get(this.baseUrl+'/show-users', this.options)
                     .pipe(
                          map((response:Response)=>response.json())
                      );

记住要这样导入map:

import { map } from 'rxjs/operators';