使用 sequelize 更新基于 id 的行的值会出现 404 错误

Update values of a row based on id with sequelize gives 404 error

我目前正在使用 nodeJS、expressJS 和 reactJS。我目前可以通过单击编辑按钮访问每个数据的 ID,但每次单击该按钮时,我实际上都在更新数据时遇到问题,我在控制台中收到 404 错误。我浏览了多个问题和教程,但 none 确实帮助我解决了困惑。我的 server.js 中有一条 put 路由,用于根据 id:

更新记录
app.put("update-list/:id", function (req, res, next) {
    Information.update({
        Name: req.body.name,
        Phone: req.body.phone,
        Email: req.body.email,
    }, { where: req.params.id }
    ).then(function (rowsUpdated) {
        res.json(rowsUpdated);
    }).catch(next)
});

在反应中定义的路线:

<Route path="/edit/:id" component={Edit}/>

我如何获得 api:

 let [state, setState] = useState({
    name: "",
    phone: "",
    email: "",
  });
  let body = state;
  useEffect(()=>{
    handleSubmit(props);
  })
  function handleSubmit(props) {
    const id=props.match.id
    axios({
      method: "put",
      url: "http://localhost:5000/update-list/"+id,
      data: body,
    })
      .then(function (response) {
        console.log(response);
      })
      .catch(function (error) {
        console.log(error);
      });

    console.log(state);
  }

关于更改功能:

function handleChange(e, field) {
    e.preventDefault();
    const value = e.target.value;
    setState({
        ...state,
        [field]: e.target.value,
    });
}

单击按钮调用 handleChange() 函数,表单调用 handleSubmit()。 我错过了什么或者这完全是错误的方法吗?如果您需要更多详细信息,请告诉我!

app.put("/update-list/:id", function (req, res, next) {
  db.Information.update({
    Name: req.body.name,
    Phone: req.body.phone,
    Email: req.body.email,
  }, { where: { id: req.params.id } } // This is fixed
  ).then(function (rowsUpdated) {
    res.json(rowsUpdated);
  }).catch(next)
});

React.js 项目:https://github.com/nkhs/node-sequelize-react.js-client/tree/stack-66271022

API 项目:https://github.com/nkhs/node-sequelize/tree/stack-66271022