【发布时间】:2021-03-13 03:47:48
【问题描述】:
我正在尝试在节点 js 中创建动态参数,其中链接 /eshop/edit/1111 将带您编辑特定产品,但每次我尝试在 /edit/ 之后添加产品代码时,我都会得到 TypeError: Cannot read property 'id' of undefined
这是我的服务器代码
router.get('/edit/:id', async (res, req) =>
{
let id = req.params.id;
let data = {
title: `Edit product ${code} | BuckStar`,
pageTitle: `Edit product ${code}`,
product: id
};
data.res = await results.editProduct(id, req.body.category, req.body.name, req.body.description, req.body.price, req.body.amount, req.body.amount, req.body.location);
res.render("page/create-edit", data)
});
【问题讨论】:
标签: javascript node.js express server