export const useProductStore = defineStore("productStore", () => { const productList = ref(); async function getList(count: number, categoryId = 1) { try { const res = await fetch( `http://127.0.0.1:4000/api/public/products/category/${categoryId}?p=1&elems=${count}`, { headers: { "Content-Type": "application/json", }, } ); if (!res.ok) { throw new Error(`HTTP error: ${res.status}`); } const data = await res.json(); productList.value = data.data.items; } catch (error) { console.error("getList error:", error); } } return { productList, getList, }; });