简体   繁体   中英

error TS2339: Property 'do' does not exist on type 'Observable<

Trying to upgrade from angular 5.2 to angular 6.0.0, we are running into the following error:

error TS2339: Property 'do' does not exist on type 'Observable<

Any ideas why?

The Code where we are using is

return this.httpClient.post<x>(`${environment.apiUrl}auth/x/`,
  this.abcd,
  httpOptions)
  .do(x1 => this.subject.next(x1))

Chain operators were deprecated a while back and now they're removed. Use pipeable operators, in this case tap replaces do .

import { tap } from 'rxjs/operators';

return this.httpClient.post(ˋ${environment.apiUrl}auth/x/ˋ, this.abcd, httpOptions)
.pipe(
    tap(x1 => this.subject.next(x1))
);
import{ scan,tap,take} from 'rxjs/operators'

do操作符现在被替换为tap操作符,所有这些 rxjs 操作符我们只能在管道内使用。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM