diff options
author | Mateja <mail@matejamaric.com> | 2021-07-24 20:19:10 +0200 |
---|---|---|
committer | Mateja <mail@matejamaric.com> | 2021-07-24 20:19:10 +0200 |
commit | fb5eb06bdd7f7a36a73a6f844006bc66c1b545e1 (patch) | |
tree | 8554abca41ff7a628bdf613f26c579f8203abb61 /client/src/views | |
parent | 72016342cbb70ddc5d7288b80baf0571bb72a8f6 (diff) | |
download | mevn-ecommerce-fb5eb06bdd7f7a36a73a6f844006bc66c1b545e1.tar.gz mevn-ecommerce-fb5eb06bdd7f7a36a73a6f844006bc66c1b545e1.zip |
Fetch products inside Vuex and display them using `ProductCard`
components.
Diffstat (limited to 'client/src/views')
-rw-r--r-- | client/src/views/Home.vue | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/client/src/views/Home.vue b/client/src/views/Home.vue index 3e89885..a71d2cb 100644 --- a/client/src/views/Home.vue +++ b/client/src/views/Home.vue @@ -1,7 +1,7 @@ <template> <div class="row mt-5"> - <div class="col-lg-3 col-md-4 col-sm-6"> - <ProductCard/> + <div v-for="product in products" :key="product._id" class="col-lg-3 col-md-4 col-sm-6"> + <ProductCard :Id="product._id" :Name="product.name" :Price="product.price" :Img="product.imagePath"/> </div> </div> </template> @@ -13,6 +13,14 @@ export default { name: 'Home', components: { ProductCard + }, + mounted() { + this.$store.dispatch('pullProducts'); + }, + computed: { + products() { + return this.$store.getters.getProducts; + } } } </script> |