const API_URL = "http://127.0.0.1:8000/products";

export async function getProducts() {
	const res = await fetch(API_URL);
	return res.json();
}

export async function getProduct(productId: number) {
	const res = await fetch(`${API_URL}/${productId}`);
	return res.json();
}

export async function createProduct(productData: any) {
	const res = await fetch(API_URL, {
		method: "POST",
		headers: { "Content-Type": "application/json" },
		body: JSON.stringify(productData),
	});
	return res.json();
}
