Created
January 24, 2020 15:44
-
-
Save AshutoshSajan/5da929cc4504115deb1d827a82fdd6cd 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 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