Skip to content

Instantly share code, notes, and snippets.

@AshutoshSajan
Created January 24, 2020 15:49
Show Gist options
  • Save AshutoshSajan/59a40dbf5ce6ee4c9457c6c2e3962423 to your computer and use it in GitHub Desktop.
Save AshutoshSajan/59a40dbf5ce6ee4c9457c6c2e3962423 to your computer and use it in GitHub Desktop.
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