diff --git a/server/controllers/captain.controller.js b/server/controllers/captain.controller.js index 60676b3e..cc4609fe 100644 --- a/server/controllers/captain.controller.js +++ b/server/controllers/captain.controller.js @@ -89,14 +89,14 @@ const captainController = { getCaptain: async (req, res) => { try { // Extract the captain ID from the request params - const { id } = req.params + const { captainId } = req.params // Query on the database to get that captain info const result = await db.query( `SELECT * FROM "Captain" WHERE "captainId" = $1`, - [id] + [captainId] ) // If captain doesn't exist return an error message @@ -124,10 +124,10 @@ const captainController = { // @access Private setCaptainType: async (req, res) => { try { - const { id } = req.params + const { captainId } = req.params const { type } = req.body - if (!id) { + if (!captainId) { return res.status(400).json({ error: "Please enter a valid id", }) @@ -146,7 +146,7 @@ const captainController = { WHERE "captainId" = $1 RETURNING * `, - [id, type]) + [captainId, type]) res.status(200).json({ message: "Successful update", diff --git a/server/routes/captain.route.js b/server/routes/captain.route.js index d7d88d9b..189f6a98 100644 --- a/server/routes/captain.route.js +++ b/server/routes/captain.route.js @@ -9,7 +9,7 @@ captainRouter.get( '/sector/:baseName/:suffixName', captainController.getCaptainsInSector ) -captainRouter.get('/:id', captainController.getCaptain) -captainRouter.patch('/:id', captainController.setCaptainType) +captainRouter.get('/:captainId', captainController.getCaptain) +captainRouter.patch('/:captainId', captainController.setCaptainType) export default captainRouter