📜  对于更新的点赞数,您应该从服务器发送更新的点赞数 - 无论代码示例

📅  最后修改于: 2022-03-11 15:00:13.128000             🧑  作者: Mango

代码示例1
app.post("/index/:id", function(req,res){
  TestData.findById(req.params.id, function(err, theUser){
      if(err){
          console.log(err);
          return res.status(500).send('Something went wrong!'); // You should notify user about any error    
      } else {
          theUser.likes += 1;
          theUser.save(function(err){
          if(err) return res.status(500).send('Something went wrong!');
          return res.send({likes_count: theUser.likes});
          });

      }
  });
});