Test getFruits action with fruit-api

This commit is contained in:
2020-12-04 02:26:50 +01:00
parent 4b1ac294bd
commit a027285357
12 changed files with 75 additions and 97 deletions

View File

@@ -1,26 +1,20 @@
<template>
<div>
<h1>Fruits Directory</h1>
{{ fruits }}
{{ this.fruits }}
</div>
</template>
<script>
import { mapState } from "vuex";
export default {
name: "Fruits",
data() {
return {
fruits: []
};
computed: {
...mapState(["fruits"])
},
async mounted() {
await this.getFruits();
},
methods: {
async getFruits() {
const response = await this.$http.get("http://localhost:3000/fruit");
this.fruits = response.data.data;
}
async created() {
await this.$store.dispatch("getFruits");
}
};
</script>