Difference between revisions of "Using your Proxy Account with Node.js"

From FoxyProxy Documentation
Jump to: navigation, search
(Created page with " <nowiki>var request = require('request'); request({'url':'http://icanhazip.com', 'proxy':'http://formshunt:verifybred@mutefish.getfoxyproxy.org:3128'}, function (erro...")
 
Line 1: Line 1:
 +
This Node.js example connects to https://icanhazip.com through a proxy server with your proxy username and password. Be sure to replace '''username''', '''password''', '''hostname.getfoxyproxy.org''' and port ('''3128''') in this example with your account information. In this example, the Node.js client connects to the proxy server using HTTP and instructs the proxy server to connect to the final destination (icanhazip.com) using HTTPS.
 +
 +
 
  <nowiki>var request = require('request');
 
  <nowiki>var request = require('request');
request({'url':'http://icanhazip.com',
+
request({'url':'https://icanhazip.com',
         'proxy':'http://formshunt:verifybred@mutefish.getfoxyproxy.org:3128'}, function (error, response, body) {
+
         'proxy':'http://username:password@hostname.getfoxyproxy.org:3128'}, function (error, response, body) {
 
     if (!error && response.statusCode == 200) {
 
     if (!error && response.statusCode == 200) {
 
         console.log(body);
 
         console.log(body);

Revision as of 03:54, 2 December 2015

This Node.js example connects to https://icanhazip.com through a proxy server with your proxy username and password. Be sure to replace username, password, hostname.getfoxyproxy.org and port (3128) in this example with your account information. In this example, the Node.js client connects to the proxy server using HTTP and instructs the proxy server to connect to the final destination (icanhazip.com) using HTTPS.


var request = require('request');
request({'url':'https://icanhazip.com',
        'proxy':'http://username:password@hostname.getfoxyproxy.org:3128'}, function (error, response, body) {
    if (!error && response.statusCode == 200) {
        console.log(body);
    }
    else console.log("error");
});

More info about the request module in Node.js, including how to install it.