add endpoint for retrieving all requested wines
This commit is contained in:
@@ -9,6 +9,7 @@ mongoose.connect("mongodb://localhost:27017/vinlottis", {
|
||||
const Purchase = require(path.join(__dirname + "/../schemas/Purchase"));
|
||||
const Wine = require(path.join(__dirname + "/../schemas/Wine"));
|
||||
const Highscore = require(path.join(__dirname + "/../schemas/Highscore"));
|
||||
const RequestedWine = require(path.join(__dirname + "/../schemas/RequestedWine"));
|
||||
const PreLotteryWine = require(path.join(
|
||||
__dirname + "/../schemas/PreLotteryWine"
|
||||
));
|
||||
@@ -103,6 +104,13 @@ router.route("/highscore/statistics").get(async (req, res) => {
|
||||
res.json(highscore);
|
||||
});
|
||||
|
||||
router.route("/wines/all-requested-wines").get(async (req, res) => {
|
||||
const allWines = await RequestedWine.find({}).populate("wine");
|
||||
|
||||
res.json(allWines);
|
||||
});
|
||||
|
||||
|
||||
router.route("/wines/statistics").get(async (req, res) => {
|
||||
const wines = await Wine.find();
|
||||
|
||||
|
||||
@@ -24,6 +24,12 @@ const overallWineStatistics = () => {
|
||||
return fetch(url.href).then(resp => resp.json());
|
||||
};
|
||||
|
||||
const allRequestedWines = () => {
|
||||
const url = new URL("/api/wines/all-requested-wines", BASE_URL);
|
||||
|
||||
return fetch(url.href).then(resp => resp.json());
|
||||
};
|
||||
|
||||
const chartWinsByColor = () => {
|
||||
const url = new URL("/api/purchase/statistics/color", BASE_URL);
|
||||
|
||||
@@ -285,6 +291,7 @@ export {
|
||||
wineSchema,
|
||||
barcodeToVinmonopolet,
|
||||
searchForWine,
|
||||
allRequestedWines,
|
||||
login,
|
||||
register,
|
||||
addAttendee,
|
||||
|
||||
@@ -1,14 +1,27 @@
|
||||
<template>
|
||||
<main>
|
||||
<p>
|
||||
<h1>
|
||||
Alle viner
|
||||
</p>
|
||||
</h1>
|
||||
<section>
|
||||
{{this.wines}}
|
||||
</section>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
import { allRequestedWines } from "@/api";
|
||||
|
||||
export default {
|
||||
data(){
|
||||
return{
|
||||
wines: undefined
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
const wines = await allRequestedWines();
|
||||
this.wines = wines
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user