这是我的路由器
router.post('/', async(req, res) => {
const posts = await loadPostsCollection()
await posts.insertOne({
text: req.body.text,
createdAt: new Date()
})
res.status(201).send()
})
Run Code Online (Sandbox Code Playgroud)
这是终端错误
在端口 3090 上进行列表 ..... (node:7764) UnhandledPromiseRejectionWarning: TypeError: 无法读取 /Users/macbook/Desktop/node-project/server/routes/api/posts.js:19 处未定义的属性“文本”: 24 在 processTicksAndRejections (internal/process/task_queues.js:94:5) (node:7764) UnhandledPromiseRejectionWarning:未处理的承诺拒绝。这个错误要么是因为在没有 catch 块的情况下抛出了异步函数,要么是因为拒绝了一个没有用 .catch() 处理过的承诺。(rejection id: 1) (node:7764) [DEP0018] DeprecationWarning:不推荐使用未处理的承诺拒绝。将来,未处理的承诺拒绝将使用非零退出代码终止 Node.js 进程。