const fetchCartItems = () => {
store.dispatch('cart/fetchCartItems');
};
const cartItems = computed(() => store.getters['cart/cartItems']);
console.log('Products is : ', cartItems.value);
watch(cartItems, (newValue) => {
console.log('Cart items updated:', newValue);
});
onMounted(() => {
fetchCartItems(); // Učitaj proizvode kada se komponenta montira
});
return {
cartItems,
};
Everything works in vuex. It downloads data from the server, but cartItems is always empty. Therefore, I cannot transfer the data to the template.
I get all the values. Watch see change to state. But it doesn’t transfer to vue.
Where am I wrong?
4