how to print the data from post request on console

前端 未结 6 1023
忘掉有多难
忘掉有多难 2021-02-18 16:07

I am trying to print the post data on my console


app.js

var express = require(\'express\')
 , http = require(\'http\');

var app         


        
6条回答
  •  悲哀的现实
    2021-02-18 16:43

    var express = require('express');
    var app = express();
    
    app.use(express.bodyParser());
    
    app.post('/post/', function(req, res) {
       // print to console
       console.log(req.body);
    
       // just call res.end(), or show as string on web
       res.send(JSON.stringify(req.body, null, 4));
    });
    
    app.listen(7002);
    

提交回复
热议问题