![](/img/trans.png)
[英]TypeError: Cannot read properties of undefined (reading 'name') when I press the Submit Button for post request
[英]when I create a post request then Error occurs ..... the error = "error": "Cannot read properties of undefined (reading 'name')"
const ProductSchema={
name:{
type: String
}} const Employee=mongoose.model('product',ProductSchema);catalogroute.post('/api/add catalogs', async(req,res)=>{
try{
const user=new Employee({
name:req.body.name
});
const val= await user.save();
res.json(val);
}
catch(e){
res.status(500).json({error: e.message});
} } );
"error": "Cannot read properties of undefined (reading 'name')"
在 post 路由中,刪除 add 和 catalogs 之間的空格,或使用 '/api/add-catalogs'。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.