Skip to content

Repository files navigation

cURL Request for Node.js

LicenseDownloads

cURL Request is a cURL wrapper, support all options and infos from cURL.

Why a cURL wrapper?

  • All node libaries i have tested are very buggy in case you use a proxy and https
  • cURL is working for all cases since years
  • The wrapper is easy to use with promises

Installing

To utilize for node.js install the the npm module:

$ npm install curl-request --save

After installing the npm package you can now start simplifying requests like so:

constcurl=new(require('curl-request'))();

If you have problems installing the dependencies, use this to build it from source:

$ npm install node-libcurl --build-from-source 

Usage

constcurl=new(require('curl-request'))();curl.setHeaders(['user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36']).get('https://www.google.com').then(({statusCode, body, headers})=>{console.log(statusCode,body,headers)}).catch((e)=>{console.log(e);});
curl.setBody({'input-arr[0]': 'input-arr-val0','input-arr[1]': 'input-arr-val1','input-arr[2]': 'input-arr-val2','input-name': 'input-val'}).post('https://www.google.com').then(({statusCode, body, headers})=>{console.log(statusCode,body,headers)}).catch((e)=>{console.log(e);});
// File uploadcurl.setHeaders(['Content-Type: multipart/form-data']).setMultipartBody([{name: 'filename',contents: 'yourimage.png'},{name: 'file',file: './yourimage.png',type: 'image/png'}]).post('https://www.google.com').then(({statusCode, body, headers})=>{console.log(statusCode,body,headers)}).catch((e)=>{console.log(e);});
// Set tor proxycurl.default.useProxy=true;curl.default.proxy='localhost:9050';curl.default.proxyType=curl.libcurl.proxy.SOCKS5_HOSTNAME;curl.default.torControlHost='localhost';curl.default.torControlPort=9051;
// New tor identitycurl.newTorIdentity();
// Verbose outputcurl.default.verbose=true;

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

About

cURL Request is a cURL wrapper, support all options and infos from cURL. Use promises, https, http, proxies and more!

Resources

Stars

25 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages