fix question vote
This commit is contained in:
parent
4b536558fc
commit
7eebd99aa9
3 changed files with 9 additions and 3 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Reference in a new issue