File
_embedded
|
_embedded: literal type
|
Type : literal type
|
_links
|
_links: literal type
|
Type : literal type
|
Optional
|
import { tap, map } from "rxjs/operators";
import { Injectable } from "@angular/core";
import { Observable } from "rxjs";
import { HttpClient } from "@angular/common/http";
import { Category } from "./category";
import { Resource } from "../../../components/hal/hal";
import { ProgressbarService } from "../../../components/progressbar/progressbar.service";
import { Link } from "../../../components/hal/hal";
export interface CategoryResource {
_embedded: {
categories: Category[];
};
_links?: {
children: Link;
};
}
@Injectable()
export class CategoryService {
constructor(
public authHttp: HttpClient,
public _progressbarService: ProgressbarService
) {}
getRootCategories(url): Observable<CategoryResource> {
this._progressbarService.addRequest();
return this.authHttp.get(url).pipe(
map((res) => <any>res),
tap(
(data) => this._progressbarService.requestFinished(),
(err) => this._progressbarService.requestFinished()
)
);
}
getCategories(childUrl: string): Observable<CategoryResource> {
this._progressbarService.addRequest();
return this.authHttp.get(childUrl).pipe(
map((res) => <any>res),
tap(
(data) => this._progressbarService.requestFinished(),
(err) => this._progressbarService.requestFinished()
)
);
}
}