You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
914 B
30 lines
914 B
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<any>();
|
|
|
|
/**
|
|
* 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<T>(operation = 'operation', result?: T) {
|
|
return (error: any): Observable<T> => {
|
|
|
|
// 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);
|
|
};
|
|
}
|
|
}
|
|
|