小编Pra*_*ina的帖子

使用减速器函数时无法读取未定义的属性“conversationId”

只是为了明确路由器使用下面的代码,我的messages.js在api文件夹中...... router.use("/messages", require("./messages")); 所以我的api调用是正确的。

用于发布消息的后端......我知道如果没有对话存在,conferenceId 将为空,但是......我正在尝试在对话已经存在的情况下发送消息,但我仍然无法读取未定义的对话 ID......

// expects {recipientId, text, conversationId } in body 
// (conversationId will be null if no conversation exists yet)
router.post("/", async (req, res, next) => {
  try {
    if (!req.user) {
      return res.sendStatus(401);
    }
    const senderId = req.user.id;
    const { recipientId, text, conversationId, sender } = req.body;

    // if we already know conversation id, we can save time and just add it to message and return
    if (conversationId) {
      const message = await Message.create({ …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs redux react-redux

5
推荐指数
1
解决办法
76
查看次数

标签 统计

javascript ×1

react-redux ×1

reactjs ×1

redux ×1