req.params.id未定义,ReferencesError:id未定义

时间:2020-06-23 23:59:11

标签: node.js

这是浏览器中的网址

http:// localhost:8888 / update / 1

这是路线的代码

router.addRoute("/update/:id", (req, res) => {
  conn.query(
    "select * from mahasiswa where ? ",
    { no_induk: req.params.id },
    function (err, rows, field) {
      if (rows.length) {
        if (req.method.toUpperCase() == "POST") {
        } else {
          let html = view.compileFile("./tamplate/form_update.html")();
          res.writeHead(200, { "Contact-Type": "text/html" });
          res.end(html);
        }
      } else {
        let html = view.compileFile("./tamplate/form_update.html")();
        res.writeHead(200, { "Contact-Type": "text/html" });
        res.end(html);
      }
    }
  );


});

请帮助我,我不知道

1 个答案:

答案 0 :(得分:0)

我认为最好使用router.post

例如:

//             --> \frac{}{}
3/             --> \frac{3}{}
4\pi^2/        --> \frac{4\pi^2}{}
(1 + 2 + 3)/   --> \frac{1 + 2 + 3}{}
(1 + (2 + 3)/) --> (1 + \frac{2 + 3}{})
(1 + (2 + 3))/ --> \frac{1 + (2 + 3)}{}