File tree Expand file tree Collapse file tree 1 file changed +15
-7
lines changed
Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change 2525
2626 <div class =" col-lg-9" >
2727
28- <div class =" row my-5" v-if =" Array.isArray(products) && products.length > 0" >
29- <div class =" col-lg-4 col-md-6 mb-4" v-for =" product in products" >
28+ <div class =" row my-5" v-if =" Array.isArray(products.data ) && products.data .length > 0" >
29+ <div class =" col-lg-4 col-md-6 mb-4" v-for =" product in products.data " >
3030 <div class =" card h-100" >
3131 <a :href =" `/product/${product.name}`" >
3232 <img class =" card-img-top" src =" http://placehold.it/700x400" alt =" " >
5353 </div >
5454 <!-- /.row -->
5555
56+ <!-- Vue pagination component we are binding data private property :data="products"
57+ and method named "loadProducts" -->
58+ <div class =" d-flex align-items-center justify-content-center" >
59+ <pagination :data =" products" @pagination-change-page =" loadProducts" ></pagination >
60+ </div >
61+
5662 </div >
63+
5764</template >
5865
5966
@@ -64,7 +71,7 @@ export default {
6471 data : function (){
6572 return {
6673 categories: [],
67- products: [] ,
74+ products: {} ,
6875 loading: true
6976 }
7077 },
@@ -87,12 +94,13 @@ export default {
8794 }
8895 );
8996 },
90- loadProducts : function (){
91- axios .get (' /api/products' ).then (response => {
92- this .products = response .data .data ;
97+ loadProducts : function (page = 1 ){
98+ axios .get (` /api/products?page=${ page} ` ).then (response => {
99+ console .log (response .data );
100+ this .products = response .data ;
93101 this .loading = false ;
94102 }).catch (err => {
95- console .log (err);
103+ console .log (' API Promise rejected error : ' , err);
96104 });
97105 }
98106 }
You can’t perform that action at this time.
0 commit comments