21 lines
595 B
TypeScript
21 lines
595 B
TypeScript
import { inject, Injectable } from "@angular/core";
|
|
import { HttpClient } from "@angular/common/http";
|
|
import { API_URL } from "../../../core/tokens/api-url-tokens";
|
|
import { ProductCollection, ProductModel } from "../../../core/models/product.model";
|
|
|
|
@Injectable({
|
|
providedIn: "root",
|
|
})
|
|
export class ProductService {
|
|
http = inject(HttpClient);
|
|
apiUrl = inject(API_URL);
|
|
|
|
getProducts() {
|
|
return this.http.get<ProductCollection>(`${this.apiUrl}/products`);
|
|
}
|
|
|
|
getProduct(slug: string) {
|
|
return this.http.get<{ data: ProductModel }>(`${this.apiUrl}/products/${slug}`);
|
|
}
|
|
}
|