Skip to content

Commit

Permalink
updated volunteer route
Browse files Browse the repository at this point in the history
  • Loading branch information
stevem-zhou committed May 6, 2024
1 parent 08627f1 commit 11241c3
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions routes/data.js
Original file line number Diff line number Diff line change
@@ -30,6 +30,18 @@ dataRouter.get('/:id', async (req, res) => {
}
});

dataRouter.get('/:id', async (req, res) => {
// Returns data from event_data table with a given event_id
try {
const { id } = req.params;
const events = await pool.query('SELECT * FROM event_data WHERE event_id =$1', [id]);

res.status(200).json(events.rows);
} catch (err) {
res.status(500).json(err.message);
}
});

dataRouter.post('/', async (req, res) => {
// Add new event to event_data table, requires event info in body
try {
@@ -196,13 +208,14 @@ dataRouter.get('/event/:eventId', async (req, res) => {
});

dataRouter.get('/volunteer/:volunteerId/event/:eventId', async (req, res) => {
// retrieves event data associated with the volunteerID and eventID
try {
const { eventId } = req.params;
const { eventId, volunteerId } = req.params;
const eventData = await pool.query(
`SELECT *
FROM event_data D
WHERE D.event_id = $1`,
[eventId],
WHERE D.event_id = $1 AND D.volunteer_id = $2`,
[eventId, volunteerId],
);
res.status(200).json(eventData.rows);
} catch (err) {

0 comments on commit 11241c3

Please sign in to comment.