Files
59f443a7-116a-4bc5-bb20-5fd…/src/lib/api/product.ts
2026-03-08 22:21:19 +00:00

22 lines
465 B
TypeScript

export interface Product {
id: string;
name: string;
price: string;
imageSrc: string;
imageAlt?: string;
description?: string;
}
export async function fetchProducts(): Promise<Product[]> {
try {
const response = await fetch('/api/products');
if (!response.ok) {
throw new Error('Failed to fetch products');
}
return response.json();
} catch (error) {
console.error('Error fetching products:', error);
return [];
}
}