PHP中文网2017-04-17 13:53:08
req is the abbreviation of request. Whether it is get post put delete or you can get the parameters through request
For example
app.post('/api/report', (req,res,next) => {
var characterId = req.body.characterId;
}
巴扎黑2017-04-17 13:53:08
Is this what you are asking?
//get
router.get('/sample/:id', function(req, res, next) {
var id = req.params.id;
});
//前端方面
$.get('/sample/2333').success()
//post
router.post('/sample/update', function(req, res, next) {
var params = req.body;
});
//前端方面
var data= {}; //some data
$.post('/sample/update', JSON.stringify(data)).success()
黄舟2017-04-17 13:53:08
router.post('/:key', function(req, res){
console.log(req.params.key);
console.log(req.body.characterId);
}