fix question vote

This commit is contained in:
“spicecat” 2022-07-26 10:05:09 -04:00
commit 7eebd99aa9
3 changed files with 9 additions and 3 deletions

View file

@ -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,

View file

@ -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,

View file

@ -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,