简体   繁体   中英

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');
unirest.get('https://api.ipify.org/t')
.end(function (response) {
 console.log(response.body);
 });

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');

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);
    });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM