相关链接:
1、https://www.jianshu.com/p/db4df1938eca
2、前端发起GET请求:http://localhost:3000/api/login?name=admin&password=123456
后端获取GET请求参数(存在于query中):
router.get('/', function(req, res, next) { console.log("query:",req.query); console.log("name:",req.query.name); console.log("password:",req.query.password); });
前端发起POST请求:http://localhost:3000/api/login/tt
{ "name":"admin", "password":"123456" }
后端获取POST请求参数(存在于body中):
router.post('/tt', function(req, res, next) { console.log("body:",req.body); console.log("name:",req.body.name); console.log("password:",req.body.password); });