Use api.js funcs over manual fetch.

This commit is contained in:
2020-10-11 18:14:43 +02:00
committed by KevinMidboe
parent 0e74534cde
commit f2989d2534
2 changed files with 4 additions and 5 deletions

View File

@@ -11,6 +11,7 @@
<script> <script>
import { page, event } from "vue-analytics"; import { page, event } from "vue-analytics";
import { prelottery } from "@/api";
import Banner from "@/ui/Banner"; import Banner from "@/ui/Banner";
import Wine from "@/ui/Wine"; import Wine from "@/ui/Wine";
@@ -25,8 +26,7 @@ export default {
}; };
}, },
async mounted() { async mounted() {
const _wines = await fetch("/api/wines/prelottery"); prelottery().then(wines => this.wines = wines);
this.wines = await _wines.json();
} }
}; };
</script> </script>

View File

@@ -29,7 +29,7 @@
</template> </template>
<script> <script>
import { getAmIWinner, postWineChosen } from "@/api"; import { getAmIWinner, postWineChosen, prelottery } from "@/api";
import Wine from "@/ui/Wine"; import Wine from "@/ui/Wine";
export default { export default {
components: { Wine }, components: { Wine },
@@ -60,8 +60,7 @@ export default {
} }
this.turn = true; this.turn = true;
this.name = winnerObject.name; this.name = winnerObject.name;
const _wines = await fetch("/api/wines/prelottery"); this.wines = await prelottery();
this.wines = await _wines.json();
}, },
methods: { methods: {
chosenWine: async function(name) { chosenWine: async function(name) {