All systems operational HTTP · HTTPS · SOCKS5 Global network
Documentation home Quickstart Engineering guides Code examples Global network Pricing Solutions overview Custom proxy pools Managed data scraping Contact Console
CODE EXAMPLE

Send Axios requests through a rotating proxy agent.

Send Axios requests through a rotating proxy agent. This example uses Rotating Proxies as the default gateway and can be adapted by replacing endpoint and routing credentials.

LanguageNode.js 20+FrameworkAxiosGatewayRotating ProxiesFilescrape.mjs
01
SETUP

Install the client and create a file.

Use a clean project environment and pin tested dependency versions for production. The example target is a public scraping sandbox.

Installnpm install axios https-proxy-agent cheerio
02
CREDENTIALS

Load proxy secrets from the environment.

The proxy username is not the LundProxy website login. Copy the complete username and password generated for the selected proxy product.

PROXY_USER=user-pool-crawlerPROXY_PASS=your-secret
03
COMPLETE EXAMPLE

scrape.mjs

Copy the code into the named file, set credentials, and run it from the project environment.

import axios from "axios";
import * as cheerio from "cheerio";
import { HttpsProxyAgent } from "https-proxy-agent";

const proxyUrl =
  "http://" +
  encodeURIComponent(process.env.PROXY_USER) + ":" +
  encodeURIComponent(process.env.PROXY_PASS) +
  "@proxy.lundproxy.com:36923";

const response = await axios.get("https://quotes.toscrape.com/", {
  httpsAgent: new HttpsProxyAgent(proxyUrl),
  proxy: false,
  timeout: 30_000,
  validateStatus: status => status >= 200 && status < 400,
});

const $ = cheerio.load(response.data);
console.log($(".quote").length);
04
WHAT THE EXAMPLE DOES

Keep the important behavior visible.

01Credential components are URL encoded.
02Axios proxy autodetection is disabled.
03The HTTPS agent owns proxy tunneling.
04Accepted status codes are explicit.
05
PRODUCTION NOTES

Add workload-specific controls before scale.

A successful sandbox run proves integration, not production readiness.

Test representative targets, response sizes, routing policy, concurrency, retries, validation, and completion window. Collect only public data you are authorized to access.

06
EXAMPLE FAQ

Axios questions.

Why set proxy to false?

It prevents Axios from applying a second proxy configuration on top of the custom agent.

Can one agent be reused?

Yes. Reuse a configured agent for matching route policy and connection behavior.

Where should retries be added?

Wrap idempotent requests with a bounded backoff policy that records attempt reasons.