Node.js (with express & bodyParser): unable to obtain form-data from post request

后端 未结 6 1794
醉酒成梦
醉酒成梦 2020-11-28 11:35

I can\'t seem to recover the form-data of a post request sent to my Node.js server. I\'ve put below the server code and the post request (sent using postman in chrome):

6条回答
  •  鱼传尺愫
    2020-11-28 12:14

    I followed this https://www.tutorialspoint.com/expressjs/expressjs_form_data.htm

    var bodyParser = require('body-parser');
    var multer = require('multer');
    var forms = multer();
    
    // apply them
    
    app.use(bodyParser.json());
    app.use(forms.array()); 
    app.use(bodyParser.urlencoded({ extended: true }));
    
    // how to use
    
    router.post('/', function(req, res) {
        console.log(req.body);
        console.log('received the widget request');
    });
    

提交回复
热议问题