gpt4 book ai didi

Angular 5 到 6 升级 : Property 'map' does not exist on type Observable

转载 作者:太空狗 更新时间:2023-10-29 16:54:39 25 4
gpt4 key购买 nike

我将我的 Angular 应用程序从版本 5 升级到版本 6,我从以下代码中收到此错误。

  const request = this.evidenceService.get().map((res) => res.data)
.catch(error => Observable.of(null));

Property 'map' does not exist on type 'Observable'.

最佳答案

运算符链接在 RXJS v6 中已经过渡到使用 .pipe(),您应该遵循 recommended migration path for RXJS .此外,catch 运算符已重命名为 catchError

现在应该这样做:

const request = this.evidenceService.get().pipe(
map((res) => res.data)),
catchError(error => Observable.of(null))
);

关于Angular 5 到 6 升级 : Property 'map' does not exist on type Observable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50203241/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com