Removed static definition of api endpoints, import from /api.js

This commit is contained in:
2020-03-10 00:26:49 +01:00
parent 386551baaf
commit 0a2cee479a
3 changed files with 10 additions and 6 deletions

View File

@@ -10,13 +10,15 @@
</template> </template>
<script> <script>
import { highscoreStatistics } from "@/api";
export default { export default {
data() { data() {
return { highscore: [] }; return { highscore: [] };
}, },
async mounted() { async mounted() {
let _response = await fetch("/api/highscore/statistics"); let response = await highscoreStatistics();
let response = await _response.json();
response.sort((a, b) => { response.sort((a, b) => {
return a.wins.length > b.wins.length ? -1 : 1; return a.wins.length > b.wins.length ? -1 : 1;
}); });

View File

@@ -35,6 +35,9 @@
</div> </div>
</template> </template>
<script> <script>
import { colorStatistics } from "@/api";
export default { export default {
data() { data() {
return { return {
@@ -54,8 +57,7 @@ export default {
}; };
}, },
async mounted() { async mounted() {
let _response = await fetch("/api/purchase/statistics/color"); let response = await colorStatistics();
let response = await _response.json();
this.red = response.red; this.red = response.red;
this.blue = response.blue; this.blue = response.blue;
this.green = response.green; this.green = response.green;

View File

@@ -35,6 +35,7 @@
<script> <script>
import { event } from "vue-analytics"; import { event } from "vue-analytics";
import Wine from "@/ui/Wine"; import Wine from "@/ui/Wine";
import { overallWineStatistics } from "@/api";
export default { export default {
components: { components: {
@@ -44,8 +45,7 @@ export default {
return { wines: [], clickedWine: null, wineOpen: false }; return { wines: [], clickedWine: null, wineOpen: false };
}, },
async mounted() { async mounted() {
let _response = await fetch("/api/wines/statistics/overall"); let response = await overallWineStatistics();
let response = await _response.json();
response.sort(); response.sort();
response = response response = response