问题
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