Express:express.json()或express.urlencoded()不起作用

时间:2014-02-13 02:11:52

标签: json node.js express

如果我写这样的帖子请求:

app.post('/sendCoins', [express.urlencoded(), express.json()], function(req, res) {
    //console.log(req.body.toAddress);
    console.log(req.body.amount);
    console.log(JSON.stringify(req.body));
    res.send('hi');
});

控制台打印undefined 但是,当我使用express.bodyParser()应用程序启动connect.multipart()时,请正确打印请求。

"123"
{"amount":"123","toAddress":"99999999"}

根据明文档,我不应该使用express.bodyParser()

0 个答案:

没有答案