Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- router.put('/update/:word', (req, res, next) => {
- // const word = new Word ({
- // word: req.body.word,
- // annotation: req.body.annotation,
- // });
- const {
- word,
- annotation,
- } = req.body;
- Word.updateOne({
- word: req.params.word,
- // annotation: req.params.annotation
- }).then(result => {
- if (result.nModified > 0) {
- res.status(200).json({
- message: "Update successful!"
- });
- } else {
- res.status(401).json({
- message: "Not authorised!"
- });
- }
- })
- .catch(error => {
- console.log(error);
- res.status(500).json({
- message: "Could not update word!"
- });
- })
- });
Add Comment
Please, Sign In to add comment