Node.js:使用参数进行 HTTP POST
call = "https://[email protected]/2010-04-01/Accounts/sasa/Calls.xml"
fields = { To : "+12321434", From : req.body.from }
request.post
url: call, body: fields (err,response,body) ->
console.log response.body
如何将字段传递给 HTTP POST 请求?
如果我传递像 "To=+12321434"
这样的字符串而不是 "To=+12321434,From = req.body.from"
,它就会起作用
call = "https://[email protected]/2010-04-01/Accounts/sasa/Calls.xml"
fields = { To : "+12321434", From : req.body.from }
request.post
url: call, body: fields (err,response,body) ->
console.log response.body
How can I pass fields to the HTTP POST request?
It works if I pass a string like "To=+12321434"
but not "To=+12321434,From = req.body.from"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要对数据进行字符串化,请看示例:
http://nodejs.org/docs/latest/api/querystring.html #querystring.stringify
You need to stringify your data, look at the example:
http://nodejs.org/docs/latest/api/querystring.html#querystring.stringify