This article provides an example of using a proxy to make an HTTP request with the NodeJS programming language.

NodeJS Code

In this example, we use the Residential proxy below:

This proxy is split into four parts separated by colons. We first save the proxy as a string variable, then split it into four parts at each colon (:) and then add it, with authentication, to our proxy dictionary.

const request = require('request');
let proxy_string = "";
let proxy_parts = proxy_string.split(':');
let ip_address = proxy_parts[0];
let port = proxy_parts[1];
let username = proxy_parts[2];
let password = proxy_parts[3];
var reqOpts = {
    url: "",
    method: "GET",
    headers: { "Cache-Control": "no-cache" },
    proxy: `http://${username}:${password}@${ip_address}:${port}`
request(reqOpts, function (err, response, body) {

Last updated