Property 'do' does not exist on type 'Observable'

后端 未结 5 1469
遇见更好的自我
遇见更好的自我 2021-02-01 02:04

After upgrading to Angular 6.0 and Rxjs to 6.0 I receive the following compilation error:

Property \'do\' does not exist on type \'Observable\'.

Her

5条回答
  •  天命终不由人
    2021-02-01 02:50

    "do" operator had replaced with "tap" operator in rxjs 6 , that why this error occurs "Property 'do' does not exist on type 'Observable'"

    To Fix this Error, you have two options

    Solution 1: Patch your code ... it will work fine with do operator

    npm install rxjs-compat@6 --save
    

    Solution 2: Replace your next.handle code with below code

     return next.handle(req).pipe(
          tap(
            event => this.handleResponse(req, event),
            error => this.handleError(req, error)
          )
        );
    

提交回复
热议问题