上代码
Router.get("/list",function (req,res) { //获取地址栏参数的key为type的值; post的参数用body获取,get的参数用 query来获取; const {type}=req.query; //查询这个关键字 键值对 User.find({type},function (err,doc) { return res.json({code:0,data:doc}); }) });
获取参数的方式
get方法 用req.query ;
post 方法用req.body;