问题:
Here is my simple form: 这是我的简单形式:
<form id="loginformA" action="userlogin" method="post">
<div>
<label for="email">Email: </label>
<input type="text" id="email" name="email"></input>
</div>
<input type="submit" value="Submit"></input>
</form>
Here is my Express.js /Node.js code: 这是我的Express.js /Node.js代码:
app.post('/userlogin', function(sReq, sRes){
var email = sReq.query.email.;
}
I tried sReq.query.email
or sReq.query['email']
or sReq.params['email']
, etc. None of them work. 我尝试了sReq.query.email
或sReq.query['email']
或sReq.params['email']
等。它们都不起作用。 They all return undefined
. 他们都返回undefined
。
When I change to a Get call, it works, so .. any idea? 当我改为Get电话时,它有效,所以..任何想法?
解决方案:
参考一: https://stackoom.com/question/NxWY/如何检索POST查询参数参考二: https://oldbug.net/q/NxWY/How-to-retrieve-POST-query-parameters
来源:oschina
链接:https://my.oschina.net/u/4438370/blog/4255600