node-curl icon indicating copy to clipboard operation
node-curl copied to clipboard

Request using POST

Open xyboox opened this issue 10 years ago • 2 comments

Hello,

I can't find anything about this in the provided documentation. Is it possible to make POST requests ( and send along some parameters )? Thanks!

xyboox avatar Feb 22 '14 14:02 xyboox

I have the same question - any examples?

dpedpe avatar Nov 24 '14 15:11 dpedpe

According to http://curl.haxx.se/libcurl/c/curl_easy_setopt.html

var qs = require('querystring');
var curl = require('node-curl');

var opts = {
  POST: 1,
  POSTFIELDS: qs.stringify({
    fleld1: someValue1,
    field2: someValue2
  })
};

curl(targetUrl, opts, function(err) {
  console.log(this.body);
});

This should print body of the HTTP response.

svlapin avatar Nov 29 '14 21:11 svlapin