Following Code:
private getJSON(): Observable<any> {
    return this.http.get('./reportNav-NEW.json')
      .map((res:any)=> res.json())
      .catch((error:any) => console.log(error));
  }
The Error gives me:
Argument of type '(error: any) => void' is not assignable to parameter of type '(err: any, caught: Observable) => ObservableInput<{}>'. Type 'void' is not assignable to type 'ObservableInput<{}>'.
It happens in the .catch((error:any) => console.log(error));
This worked for me (thanks to @trevor in the comments)
private getJSON(): Observable<any> {
    console.log(document.location.href);
    return this.http.get('...')
      .map((res:any)=> res.json())
      .catch((error:any) => {
        return Observable.throw(error);
      })
  }
update: Now with rxjs 6 you have to call "throwError" operator from "rxjs/operators", and use it instead of "Observable.throw".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With