Node.js:使用params进行HTTP POST

时间:2012-02-12 03:05:11

标签: node.js coffeescript twilio

call = "https://aaa@api.twilio.com/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"

之类的字符串,则此功能正常

1 个答案:

答案 0 :(得分:4)

您需要对数据进行字符串化,请查看示例: http://nodejs.org/docs/latest/api/querystring.html#querystring.stringify