2012-12-23 53 views
2

我是新来的JS, 我看到了很多的代码我读express.js - req.body?

_.pick(req.body, ' ' , ' ') 

是什么req.body办? 什么时候可以说req.body.something?

+0

您可以在您的问题中添加更多详细信息吗? – alditis

+0

http://stackoverflow.com/questions/4295782/node-js-extracting-post-data – Damodaran

回答

18

req.body保存作为POST请求的一部分从客户端发送的参数。请参阅API

// POST user[name]=tobi&user[email][email protected] 
req.body.user.name 
// => "tobi" 

req.body.user.email 
// => "[email protected]" 

// POST { "name": "tobi" } 
req.body.name 
// => "tobi" 
+0

如果从服务器而不是客户端发送了某些内容,并且当您收到来自服务器的某些请求时如何协调这两者客户端和其他人从服务器? – rashadb