Install axios + Test App rendering + Test API connection
This commit is contained in:
@@ -2,8 +2,10 @@ import Vue from "vue";
|
||||
import App from "./App.vue";
|
||||
import router from "./router";
|
||||
import store from "./store";
|
||||
import axios from "axios";
|
||||
|
||||
Vue.config.productionTip = false;
|
||||
Vue.prototype.$http = axios;
|
||||
|
||||
new Vue({
|
||||
router,
|
||||
|
||||
@@ -1,11 +1,26 @@
|
||||
<template>
|
||||
<div>
|
||||
<h1>Fruits Directory</h1>
|
||||
{{ fruits }}
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "Fruits"
|
||||
name: "Fruits",
|
||||
data() {
|
||||
return {
|
||||
fruits: []
|
||||
};
|
||||
},
|
||||
async mounted() {
|
||||
await this.getFruits();
|
||||
},
|
||||
methods: {
|
||||
async getFruits() {
|
||||
const response = await this.$http.get("http://localhost:3000/fruit");
|
||||
this.fruits = response.data.data;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user