controllers/thoughtController.js
// Add a reaction to a thought
Add a reaction to a thought
Add a reaction to a thought
addReaction(req, res) {
    console.log("You are adding an reaction");
    console.log(req.body);
    Thought.findOneAndUpdate(
      { _id: req.params.thoughtId },
      { $addToSet: { reactions: req.body } },
      { runValidators: true, new: true }
    )
      .then((thought) =>
        !thought
          ? res.status(404).json({ message: "No thought found with that ID" })
          : res.json(thought)
      )
      .catch((err) => res.status(500).json(err));
  }
addReaction ( req , res ) { console . log ( "You are adding an reaction" ) ; console . log ( req . body ) ; Thought . findOneAndUpdate ( { _id : req . params . thoughtId } , { $addToSet : { reactions : req . body } } , { runValidators : true , new : true } ) . then ( ( thought ) => ! thought ? res . status ( 404 ) . json ( { message : "No thought found with that ID" } ) : res . json ( thought ) ) . catch ( ( err ) => res . status ( 500 ) . json ( err ) ) ; }
Add a reaction to a thought
Add a reaction to a thought