Skip to content

Instantly share code, notes, and snippets.

@AshutoshSajan
Created January 24, 2020 15:44
Show Gist options
  • Save AshutoshSajan/5da929cc4504115deb1d827a82fdd6cd to your computer and use it in GitHub Desktop.
Save AshutoshSajan/5da929cc4504115deb1d827a82fdd6cd to your computer and use it in GitHub Desktop.
function getQuestion(req, res) {
const id = req.params.id;
Question.findOne({
_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,
question
});
} 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