title: How to solve catch error in Observable in angular 8?
body: <p>I do error handler code, but I got error in catch. undefined method. </p>
  
  <p>This is my serivce.ts code.</p>
  
  <pre><code>import { Injectable } from "@angular/core";
  import { HttpClient, HttpErrorResponse } from "@angular/common/http";
  import { user } from "./user";
  import { Observable } from "rxjs";
  import "rxjs/add/operator/catch";
  import "rxjs/add/Observable/throw";
  @Injectable({
    providedIn: "root"
  })
  export class DemoService {
    private url: string = "/assets/demo/user.json";
    constructor(private http: HttpClient) {}
  
    getuserdetails(): Observable&lt;user[]&gt; {
      return this.http.get&lt;user[]&gt;(this.url).catch(this.errorHandler);
    }
    errorHandler(error: HttpErrorResponse) {
      return Observable.throw(error.message || "server error.");
    }
  }
  </code></pre>
  
  <p>This is my app.component.ts file code</p>
  
  <pre><code> public userdetails = [];
    public errorMsg;
    constructor(private user: DemoService) {}
    ngOnInit() {
      this.user
        .getuserdetails()
        .subscribe(
          $data =&gt; (this.userdetails = $data),
          error =&gt; (this.errorMsg = error)
        );
    } 
  </code></pre>
  
  <p>I got error in catch. and error message is Property 'catch' does not exist on type 'Observable'.</p>