Files
brewman/overlord/src/app/core/batch.service.ts
tanshu de4d248de7 Done:
Issue Grid
 Batch
2020-05-12 11:53:20 +05:30

25 lines
809 B
TypeScript

import {Injectable} from '@angular/core';
import {Observable} from 'rxjs/internal/Observable';
import {catchError} from 'rxjs/operators';
import {HttpClient, HttpParams} from '@angular/common/http';
import {Batch} from './voucher';
import {ErrorLoggerService} from './error-logger.service';
const url = '/api/batch';
const serviceName = 'BatchService';
@Injectable({providedIn: 'root'})
export class BatchService {
constructor(private http: HttpClient, private log: ErrorLoggerService) {
}
autocomplete(date: string, term: string): Observable<Batch[]> {
const options = {params: new HttpParams().set('q', term).set('d', date)};
return <Observable<Batch[]>>this.http.get<Batch[]>(url, options)
.pipe(
catchError(this.log.handleError(serviceName, 'autocomplete'))
);
}
}