add map/products

This commit is contained in:
2025-06-03 15:20:55 +02:00
parent 2ffd64da98
commit c9348dc092
17 changed files with 572 additions and 46 deletions

30
stores/productStore.ts Normal file
View File

@ -0,0 +1,30 @@
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,
};
});