Unirest - Setting proxy

旧巷老猫 提交于 2019-12-11 19:14:06

问题


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

回答1:


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



回答2:


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


来源:https://stackoverflow.com/questions/52935965/unirest-setting-proxy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!