diff --git a/src/lib/api/product.ts b/src/lib/api/product.ts index 3e93c15..5941d50 100644 --- a/src/lib/api/product.ts +++ b/src/lib/api/product.ts @@ -1,6 +1,14 @@ -export const fetchProducts = async () => { +export interface Product { + id: string; + name: string; + price: number; + description?: string; + imageSrc?: string; + category?: string; +} + +export const fetchProducts = async (): Promise => { try { - // Fetch products from API const response = await fetch("/api/products"); const data = await response.json(); return data; @@ -10,9 +18,8 @@ export const fetchProducts = async () => { } }; -export const fetchProductDetail = async (id: string) => { +export const fetchProduct = async (id: string): Promise => { try { - // Fetch single product from API const response = await fetch(`/api/products/${id}`); const data = await response.json(); return data; @@ -21,3 +28,7 @@ export const fetchProductDetail = async (id: string) => { return null; } }; + +export const fetchProductDetail = async (id: string): Promise => { + return fetchProduct(id); +};