Handling text/plain in Express (via connect)?

前端 未结 5 796
轻奢々
轻奢々 2020-12-15 01:37

I am using Express 3, and would like to handle text/plain POSTs.

Express 3 uses connect\'s bodyParser now (I think the old Express code got moved t

5条回答
  •  渐次进展
    2020-12-15 02:20

    You may try this :

    var expressApi= (req, res,params)=>{
        console.log('req.body',params);
        var body = '';
        req.on('data', function (data) {
            body += data;
        });
        req.on('end', function () {
            res.write({status:200,message:'read data'}); 
        }); 
    }
    

提交回复
热议问题