interface Instance {
// don't know what goes here, but don't want to perpetuate `any` abuse
}
getInstances(): Observable<Instance[]> {
return from(this.localStorage.getEtagInstances()).pipe(
switchMap(etag => {
let headers = new HttpHeaders().append("accept-language", localLanguage);
if (etag) { // i avoid direct comparison against null as much as possible
headers = headers.append("If-None-Match", etag);
}
return this.http.get<Instance[]>(BACKEND_URL + "/api/ROUTE",
{headers, params, observe: "response"});
}),
tap(rsp => this.localStorage.setEtagInstances(rsp.headers.get("etag")))
);
}
2 Likes