Created
January 24, 2020 15:49
-
-
Save AshutoshSajan/59a40dbf5ce6ee4c9457c6c2e3962423 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function deleteQuestion (req, res) { | |
const id = req.params.id; | |
Question.findOneAndDelete({ | |
_id: id | |
}, (err, question) => { | |
if (err) { | |
res.status(500).json({ | |
success: false, | |
error: err, | |
message: "server error" | |
}); | |
} else if (question) { | |
res.status(200).json({ | |
success: true, | |
message: 'question deleted' | |
}); | |
} else { | |
res.status(404).json({ | |
success: false, | |
message: 'page not found' | |
}) | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment