Generic http error handling in Angular
问题 angular2-jwt provides an AuthHttp wrapper for the native Angular http class that automatically includes the http authorization header with each request. In my services I am usually calling a backend api like this getThings(): Observable<Thing[]> { return this.http.get(environment.apiEndpoint + '/things') .map(res => res.json().data) .catch(res => this.handleError(res)); } with an error handler like private handleError(error: Response | any) { let errMsg: string; if (error instanceof Response)