Mongoose 使用FindByIdAndUpdate放置请求

Mongoose 使用FindByIdAndUpdate放置请求,mongoose,Mongoose,我知道我遗漏了一些东西,但就是想不出来,希望你能帮我。这是我的密码: const express=require(“express”); const Appointment=require(“../models/Appointment”); const router=express.router(); 路由器.get(“/”,(请求,res)=>{ Appointment.find({},(err,data)=>{ 如果(错误){ 返回res.status(500.json(); }否则{ 返回

我知道我遗漏了一些东西,但就是想不出来,希望你能帮我。这是我的密码:

const express=require(“express”);
const Appointment=require(“../models/Appointment”);
const router=express.router();
路由器.get(“/”,(请求,res)=>{
Appointment.find({},(err,data)=>{
如果(错误){
返回res.status(500.json();
}否则{
返回res.json(数据);
}
});
});
路由器.put(“/:id)”,(请求,res)=>{
const id=req.params.id;
const appointment=新任命(请求主体);
Appointment.findByIdAndUpdate(id,(错误,数据)=>{
如果(错误){
返回res.status(500.json();
}否则{
返回res.json(数据);
}
});
});
module.exports=路由器;

在那之后,我在邮递员
中遇到了一个错误,无法得到任何回复。我的应用程序正在运行,所以这不是问题。

您的控制台(服务器)是否出现任何错误?如果有,请分享不,我没有,这就是为什么我很难找到问题的原因。这个路由器绑定到的
路径如何?你可以发布你的
应用程序。使用('somePath',thisRouter)
代码片段吗?你有这个代码
const appointment=new appointment(req.body)
,但你不在任何地方使用appointment。此外,您没有在findByIdAndUpdate中设置任何更新的对象。