【问题标题】:TypeError: Cannot read properties of undefined (reading 'x')TypeError:无法读取未定义的属性(读取 \'x\')
【发布时间】:2022-09-22 22:41:27
【问题描述】:

我是 MEAN 堆栈的新手,并试图获得一些基本的帖子。我正进入(状态TypeError:无法读取未定义的属性(正在读取 \'title\')发帖时。这在更改 todo-route.js 时有效

标题:req.body.title,

内容:req.body.content

标题:\"SomeTextTitle\",

内容:\"一些内容\"

我对 req 正文如何传递给 post 函数有一个断开连接

索引.js

todo-route.js

todo-repo.js

  • 请不要发布屏幕截图代替代码
  • 该错误表示属性“body”上不存在属性“title”,这反过来意味着您没有为您的请求提供“body”。

标签: angular express mean-stack


【解决方案1】:

我认为您还没有解析您的请求正文。如果不使用,请使用 body Parser。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-11-26
    • 2021-11-24
    • 2021-12-20
    • 2021-11-27
    • 2022-01-21
    • 2021-12-04
    • 2021-12-09
    • 2021-12-06
    相关资源
    最近更新 更多