Python 接受django对nodejs的Post请求

Python 接受django对nodejs的Post请求,python,node.js,django,express,python-requests,Python,Node.js,Django,Express,Python Requests,我正在向nodejs发出django的发帖请求 v = {} v['id'] = 'test' y=requests.post('http://localhost:3000',params=v) 如何在nodejs中解析此数据?下面是我的代码,但它显示未定义 app.post('/', function (req, res) { console.log(req.body.id) //this shows Cannot read property 'id' of undefined

我正在向nodejs发出django的发帖请求

v = {}
v['id'] = 'test'
y=requests.post('http://localhost:3000',params=v)
如何在nodejs中解析此数据?下面是我的代码,但它显示未定义

app.post('/', function (req, res) {
    console.log(req.body.id)  //this shows Cannot read property 'id' of undefined
    res.send('hello')
})

请注意,对于python requets,POST动词期望字典为
data

v = {}
v['id'] = 'test'
y=requests.post('http://localhost:3000',data=v)
params通常由get动词使用。话虽如此,我不知道为什么要用这种方式连接django和node。用一种或另一种方式来写整件事不是更容易吗

您启用了主体解析器吗

var bodyParser = require('body-parser');
app.use(bodyParser.json()); // support json encoded bodies
app.use(bodyParser.urlencoded({ extended: true })); // support encoded bodies

完成但仍然不起作用我这样做是因为数据密集型任务,nodejs可以以更好的方式异步处理。我不是express方面的专家,但您是否启用了body解析器?如果您在评论中提到这对您有效,请您将其标记为正确。谢谢