-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCardClubView.js
38 lines (30 loc) · 960 Bytes
/
CardClubView.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const { Events } = require("../models/Events");
const Express = require("express");
const _ = require("lodash");
const router = Express.Router();
//importing middle ware
const AuthenticateUser = require("../middleware/AuthenticateUser");
const RedirectAdminUser = require("../middleware/RedirectAdminUser");
router.get("/", AuthenticateUser, async (request, response) => {
const Events = await Events.find({});
const cateories = [];
Events.forEach((event) => {
if (!categories.includes(event.Category)) {
clubs.push(event.Category);
}
});
response.status(200).send(categories);
});
router.get(
"/fetchEvents/:Category",
AuthenticateUser,
async (request, response) => {
const Category = request.params.Category;
const EventsConductedCategory = await Events.find({
Category: Category,
});
//for debugging purposes
response.status(200).send(EventsConductedCategory);
}
);
module.exports = router;