How to read products array on getSales, for others uses?
document.addEventListener("alpine:init", () => {
Alpine.store("getProducts", {
url: "http://localhost:3000/products",
products: [],
getAllProducts() {
fetch(this.url)
.then((response) => response.json())
.then((data) => (this.products = data));
},
});
});
const getSales = () => ({
products: $store.getProducts.products
})