Skip to content

Commit 7fce9e2

Browse files
committed
Display data from API on website
1 parent 702535c commit 7fce9e2

File tree

3 files changed

+26
-31
lines changed

3 files changed

+26
-31
lines changed

public/js/app.js

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16286,6 +16286,11 @@ __webpack_require__.r(__webpack_exports__);
1628616286
/* harmony export */ "default": () => __WEBPACK_DEFAULT_EXPORT__
1628716287
/* harmony export */ });
1628816288
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
16289+
data: function data() {
16290+
return {
16291+
products: null
16292+
};
16293+
},
1628916294
mounted: function mounted() {
1629016295
var _this = this;
1629116296

@@ -16294,18 +16299,16 @@ __webpack_require__.r(__webpack_exports__);
1629416299
console.log("We got a response!");
1629516300
console.log(response.data);
1629616301
_this.products = response.data;
16302+
console.log(_this.products);
1629716303
})["catch"](function (error) {
1629816304
return console.error(error);
1629916305
});
16300-
},
16301-
// props: ["foo"],
16302-
setup: function setup() {
16303-
//const greeting = "Greetings";
16304-
var products = {};
16305-
return {
16306-
products: products
16307-
};
1630816306
}
16307+
/*setup() {
16308+
const products = {};
16309+
return { products };
16310+
},*/
16311+
1630916312
});
1631016313

1631116314
/***/ }),
@@ -16323,20 +16326,14 @@ __webpack_require__.r(__webpack_exports__);
1632316326
/* harmony export */ });
1632416327
/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.esm-bundler.js");
1632516328

16326-
16327-
var _hoisted_1 = /*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_0__.createTextVNode)(" Testing out API ");
16328-
16329-
var _hoisted_2 = {
16329+
var _hoisted_1 = {
1633016330
key: 0
1633116331
};
16332-
16333-
var _hoisted_3 = /*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_0__.createTextVNode)(" Products is true ... ");
16334-
1633516332
function render(_ctx, _cache, $props, $setup, $data, $options) {
16336-
return (0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)("div", null, [_hoisted_1, $setup.products ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)("div", _hoisted_2, [_hoisted_3, ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(true), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)(vue__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,vue__WEBPACK_IMPORTED_MODULE_0__.renderList)($setup.products, function (product) {
16333+
return (0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)("div", null, [$data.products ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)("div", _hoisted_1, [((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(true), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)(vue__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,vue__WEBPACK_IMPORTED_MODULE_0__.renderList)($data.products, function (product) {
1633716334
return (0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)("div", {
1633816335
key: product.id
16339-
}, " Echoing out name: " + (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)(product.name), 1
16336+
}, (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)(product.id) + " - " + (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)(product.name) + " - " + (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)(product.description) + " - " + (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)(product.price), 1
1634016337
/* TEXT */
1634116338
);
1634216339
}), 128

resources/js/components/NewComponent.vue

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
<template>
22
<div>
3-
Testing out API
43
<div v-if="products">
5-
Products is true ...
64
<div v-for="product in products" :key="product.id">
7-
Echoing out name:
8-
{{ product.name }}
5+
{{ product.id }} - {{ product.name }} -
6+
{{ product.description }} - {{ product.price }}
97
</div>
108
</div>
119
</div>
1210
</template>
1311

1412
<script>
1513
export default {
14+
data() {
15+
return {
16+
products: null,
17+
};
18+
},
1619
mounted() {
1720
axios
1821
.get("/api/products")
@@ -21,15 +24,15 @@ export default {
2124
console.log("We got a response!");
2225
console.log(response.data);
2326
this.products = response.data;
27+
console.log(this.products);
2428
})
2529
.catch((error) => console.error(error));
2630
},
27-
// props: ["foo"],
28-
setup() {
29-
//const greeting = "Greetings";
31+
32+
/*setup() {
3033
const products = {};
3134
return { products };
32-
},
35+
},*/
3336
};
3437
</script>
3538

resources/views/welcome.blade.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,8 @@
2626
@endif
2727

2828
<div id="app">
29-
30-
<test-component foo="bar1"></test-component>
31-
<new-component foo="bar2"></new-component>
32-
33-
<div class="text-white bg-black">White text</div>
29+
<new-component></new-component>
3430
</div>
35-
3631
<script src="{{ mix('js/app.js') }}"></script>
3732
</body>
3833
</html>

0 commit comments

Comments
 (0)