Integrations / Language
Use Proxys with Node.js (fetch and undici)
Use Proxys with Node's fetch through undici's ProxyAgent.
Steps
- Install undici: npm i undici.
- Create a ProxyAgent and pass it as the dispatcher.
import { ProxyAgent, fetch } from "undici";
const agent = new ProxyAgent("http://USERNAME-country-us:PASSWORD@gw.proxys.co:8000");
const res = await fetch("https://ipinfo.io/json", { dispatcher: agent });
console.log(await res.json());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.