Skip to content

Commit 866c3cc

Browse files
author
ahmadhussnain
committed
Updated component FrontPage.vue
1 parent 0eb3163 commit 866c3cc

File tree

3 files changed

+41
-9
lines changed

3 files changed

+41
-9
lines changed

public/js/app.js

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2330,14 +2330,22 @@ __webpack_require__.r(__webpack_exports__);
23302330
//
23312331
//
23322332
//
2333+
//
2334+
//
2335+
//
2336+
//
2337+
//
2338+
//
2339+
//
23332340
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
23342341
name: 'FrontPage',
23352342
// Public properties
23362343
data: function data() {
23372344
return {
23382345
categories: [],
2339-
products: {},
2340-
loading: true
2346+
products: [],
2347+
loading: true,
2348+
error: false
23412349
};
23422350
},
23432351
// Private method runs before the component is mount on the screen
@@ -2357,7 +2365,7 @@ __webpack_require__.r(__webpack_exports__);
23572365
axios.get('/api/categories').then(function (response) {
23582366
_this.categories = response.data.data;
23592367
})["catch"](function (err) {
2360-
console.log('API Promise rejected error :', err);
2368+
console.log('API Promise rejected error categories :', err);
23612369
});
23622370
},
23632371
loadProducts: function loadProducts() {
@@ -2369,7 +2377,9 @@ __webpack_require__.r(__webpack_exports__);
23692377
_this2.products = response.data;
23702378
_this2.loading = false;
23712379
})["catch"](function (err) {
2372-
console.log('API Promise rejected error :', err);
2380+
_this2.error = true;
2381+
_this2.loading = false;
2382+
console.log('API Promise rejected error products:', err);
23732383
});
23742384
}
23752385
}
@@ -21236,6 +21246,10 @@ var render = function() {
2123621246
? _c("div", { staticClass: "loading-wrapper" }, [_vm._m(0)])
2123721247
: _vm._e(),
2123821248
_vm._v(" "),
21249+
_vm.error
21250+
? _c("div", { staticClass: "loading-wrapper" }, [_vm._m(1)])
21251+
: _vm._e(),
21252+
_vm._v(" "),
2123921253
_c("div", { staticClass: "row" }, [
2124021254
_c("div", { staticClass: "col-lg-3" }, [
2124121255
_c("h1", { staticClass: "my-4" }, [_vm._v("Shop Catalog")]),
@@ -21341,6 +21355,14 @@ var staticRenderFns = [
2134121355
},
2134221356
[_c("span", { staticClass: "sr-only" }, [_vm._v("Loading...")])]
2134321357
)
21358+
},
21359+
function() {
21360+
var _vm = this
21361+
var _h = _vm.$createElement
21362+
var _c = _vm._self._c || _h
21363+
return _c("div", { staticClass: "text-center text-secondary" }, [
21364+
_c("h1", [_vm._v("Sorry, No records found!")])
21365+
])
2134421366
}
2134521367
]
2134621368
render._withStripped = true

public/mix-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"/js/app.js": "/js/app.js?id=9b3ca8fc4628b8185ebe",
2+
"/js/app.js": "/js/app.js?id=fea10c95716ae2f53fd0",
33
"/css/app.css": "/css/app.css?id=aefe1876af1802310a0f"
44
}

resources/js/components/FrontPage.vue

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
</div>
1212
</div>
1313

14+
<!-- If there is an Error please show -->
15+
<div class="loading-wrapper" v-if="error">
16+
<div class="text-center text-secondary">
17+
<h1>Sorry, No records found!</h1>
18+
</div>
19+
</div>
20+
1421
<div class="row">
1522

1623
<div class="col-lg-3">
@@ -72,8 +79,9 @@ export default {
7279
data: function(){
7380
return {
7481
categories: [],
75-
products: {},
76-
loading: true
82+
products: [],
83+
loading: true,
84+
error: false
7785
}
7886
},
7987
// Private method runs before the component is mount on the screen
@@ -91,7 +99,7 @@ export default {
9199
axios.get('/api/categories').then(response => {
92100
this.categories = response.data.data;
93101
}).catch(err => {
94-
console.log('API Promise rejected error :', err);
102+
console.log('API Promise rejected error categories :', err);
95103
}
96104
);
97105
},
@@ -101,7 +109,9 @@ export default {
101109
this.products = response.data;
102110
this.loading = false;
103111
}).catch(err => {
104-
console.log('API Promise rejected error :', err);
112+
this.error = true;
113+
this.loading = false;
114+
console.log('API Promise rejected error products:', err);
105115
});
106116
}
107117
}

0 commit comments

Comments
 (0)