简体   繁体   English

SailsJS获取发布的数据

[英]SailsJS get posted data

I've tried getting the post data in my controller actions using the following: 我尝试使用以下命令在控制器操作中获取发布数据:

req.body.name

but it doesn't work 但这不起作用

you can try to access them by first retrieving them all 您可以先检索全部内容以尝试访问它们

function(req, res, next) {
    var params = req.params.all();
    //then you can access them like this...
     console.log(params.name)
  }

If you input-field have the name "name" you can do: 如果输入字段的名称为“名称”,则可以执行以下操作:

req.param("name")

See: http://beta.sailsjs.org/#/documentation/reference/Request/req.param.html 请参阅: http : //beta.sailsjs.org/#/documentation/reference/Request/req.param.html

Try req.allParams() to try to find it in the variable structure. 尝试req.allParams()尝试在变量结构中找到它。 You might have it misspelled somewhere or something else amiss. 您可能在某个地方拼写错误或其他错误。 http://beta.sailsjs.org/#/documentation/reference/Request/req.allParams.html http://beta.sailsjs.org/#/documentation/reference/Request/req.allParams.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM