import {Injectable} from '@angular/core'; import {catchError} from 'rxjs/operators'; import {Observable} from 'rxjs/internal/Observable'; import {HttpClient, HttpHeaders} from '@angular/common/http'; import {ClosingStock} from './closing-stock'; import {ErrorLoggerService} from '../core/error-logger.service'; const httpOptions = { headers: new HttpHeaders({'Content-Type': 'application/json'}) }; const url = '/api/ClosingStock'; const serviceName = 'AccountService'; @Injectable({ providedIn: 'root' }) export class ClosingStockService { constructor(private http: HttpClient, private log: ErrorLoggerService) { } list(date: string): Observable { const listUrl = (date === null) ? url : `${url}/${date}`; return >this.http.get(listUrl) .pipe( catchError(this.log.handleError(serviceName, 'list')) ); } }