diff --git a/client/src/components/QAComponents/Question.jsx b/client/src/components/QAComponents/Question.jsx index a3492f3..3d90e09 100644 --- a/client/src/components/QAComponents/Question.jsx +++ b/client/src/components/QAComponents/Question.jsx @@ -14,13 +14,13 @@ const statusColor = (status) => { } export default function Question({ + _id: question_id, answers, comments, creator, createdAt, downvotes, hasAcceptedAnswer, - question_id, status, title, text, diff --git a/server/routes/question/EditAnswerVote.js b/server/routes/question/EditAnswerVote.js index 212ed68..3b21a21 100644 --- a/server/routes/question/EditAnswerVote.js +++ b/server/routes/question/EditAnswerVote.js @@ -25,7 +25,10 @@ async function EditAnswerVote(req, res) { const URL = `/questions/${questionID}/answers/${answerID}/vote/${user.username}`; // Get the cached vote and answer, refresh cache if not present - const cachedAnswer = await Answer.findById(answerID); + let cachedAnswer; + try { cachedAnswer = await Question.findById(answerID); } + catch { return res.status(400).send(config.errorNotFound); } + let cachedVote = await Vote.findOneAndDelete({ parentID: answerID, creator: user.username, diff --git a/server/routes/question/EditQuestionVote.js b/server/routes/question/EditQuestionVote.js index 0c01f3a..7143b26 100644 --- a/server/routes/question/EditQuestionVote.js +++ b/server/routes/question/EditQuestionVote.js @@ -22,7 +22,10 @@ async function EditQuestionVote(req, res) { const URL = `/questions/${questionID}/vote/${user.username}`; - const cachedQuestion = await Question.findById(questionID); + let cachedQuestion; + try { cachedQuestion = await Question.findById(questionID); } + catch { return res.status(400).send(config.errorNotFound); } + let cachedVote = await Vote.findOneAndDelete({ parentID: questionID, creator: user.username,