export const useProductsStore = defineStore("products", () => { const products = ref<TProduct[] | undefined>();
async function setProducts() { if (products.value !== undefined) return; // if it’s not necessary to block script execution here, use “then” instead of “await“ products.value = ( await fetchData( "https://dummyjson.com/products?limit=5" ) ).products; }
return { products, }; });