exports.getOneSauce = (req, res, next) => { // mongoose model // targets _id = must be the same as the req param Sauce.findOne({ _id: req.params.id }) .then((sauce) => res.status(200).json(sauce)) .catch((error) => res.status(404).json({ error })); };
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter