22 lines
465 B
TypeScript
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 [];
|
|
}
|
|
}
|