Node.js 无法读取属性';用户';未定义&;删除/api/profile/id 500 168.563 ms-148

Node.js 无法读取属性';用户';未定义&;删除/api/profile/id 500 168.563 ms-148,node.js,Node.js,路由器.delete('/id',passport.authenticate('jwt',{session:false}),(req,res)=>{ )如果用户的id在url中,您可以通过req.params访问它,而不是req.bodyreq.body.id是未定义的可能值得控制台登录req.body以查看用户的确切位置,如果有,您可以更新编码并显示如何访问它? User.findOne({ _id: req.body.id.user }).then(user => {

路由器.delete('/id',passport.authenticate('jwt',{session:false}),(req,res)=>{


)如果
用户的
id
url
中,您可以通过
req.params
访问它,而不是
req.body
req.body.id
未定义的
可能值得控制台登录
req.body
以查看
用户的确切位置,如果有,您可以更新编码并显示如何访问它?
  User.findOne({ _id: req.body.id.user }).then(user => {

      if (user) {
          if (user.hasProfile) {
              Profile.findOneAndRemove({ user: req.body.id.user }).then(() => {
                  User.findOneAndRemove({ _id: req.body.id.user }).then(() =>
                    res.json({ success: true })
                  );
              });
          }
          else {
              User.findOneAndRemove({ _id: req.body.id.user }).then(() =>

                res.json({ success: true })
              );
          }
      }
  });
}