Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js: Make a HTTP POST with params

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"

like image 644
donald Avatar asked Mar 06 '26 07:03

donald


1 Answers

You need to stringify your data, look at the example: http://nodejs.org/docs/latest/api/querystring.html#querystring.stringify

like image 143
Lebovski Avatar answered Mar 07 '26 19:03

Lebovski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!