Unirest - 设置代理

Unirest - Setting proxy

如何使用 unirest 为其余请求设置一次代理?我得到 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 目前支持http 代理。代码应该如下:

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

声明后每个请求都将通过代理传递

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

这会很好用:

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