Skip to content Skip to sidebar Skip to footer

Unirest - Setting Proxy

How do I set a proxy once for the rest of the requests with unirest? I get Request.proxy is not a function var Request = require('unirest'); Request.proxy('217.23.3.15:11100'); un

Solution 1:

this will work fine :

    unirest.get('https://api.ipify.org/t')
    .proxy('http://217.23.3.15:11100')
    .end(function (response) {
      console.log(response.body);
    });

Solution 2:

Unirest support http proxy for now. The code should be as follows:

var Request = require('unirest');
Request.proxy('http://217.23.3.15:11100');
unirest.get('https://api.ipify.org/t')
.end(function (response) {
  console.log(response.body);
});

Every request will be passed through proxy once you declare

Request.proxy('http://217.23.3.15:11100');

Post a Comment for "Unirest - Setting Proxy"