openaire-library/utils/indexInfo.service.ts

24 lines
657 B
TypeScript
Raw Normal View History

import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {EnvProperties} from './properties/env-properties';
import {Observable, of} from "rxjs";
import {catchError, map} from "rxjs/operators";
@Injectable({
providedIn: "root"
})
export class IndexInfoService {
constructor(private http: HttpClient) {
}
getLastIndexDate(properties: EnvProperties): Observable<any> {
let url = properties.indexInfoAPI;
return this.http.get((properties.useLongCache)? (properties.cacheUrl+encodeURIComponent(url)): url).pipe(map(res => res['claim_load_date'])).pipe(catchError(err => {return of(null)}));
}
}