import {HttpInterface} from './HttpInterface'; import {Observable, of} from 'rxjs'; import {HttpHeaders} from '@angular/common/http'; import {JSONResponse} from './JSONResponse'; export abstract class JSONRequest { protected httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json' }) }; protected httpError = new JSONResponse(); /** * Handle Http operation that failed. * Let the app continue. * @param operation - name of the operation that failed * @param result - optional value to return as the observable result */ protected handleError(operation = 'operation', result?: T) { return (error: any): Observable => { // TODO: send the error to remote logging infrastructure console.error(error); // log to console instead // Let the app keep running by returning an empty result. return of(result as T); }; } }