Integrations / Language
Use Proxys with Axios
Use Proxys with axios through an HTTPS proxy agent.
Steps
- Install axios and https-proxy-agent.
- Pass the agent as httpsAgent and turn off axios's own proxy handling.
import axios from "axios";
import { HttpsProxyAgent } from "https-proxy-agent";
const agent = new HttpsProxyAgent("http://USERNAME-country-us:PASSWORD@gw.proxys.co:8000");
const { data } = await axios.get("https://ipinfo.io/json", { httpsAgent: agent, proxy: false });
console.log(data);Before you start
Replace USERNAME and PASSWORD with a sub-user's credentials from the dashboard. Change -country-us to the country you need, or remove it for a random location. See targeting options for city, ASN and sticky sessions.