Use AnonEdge proxies with Axios using the built-in proxy option or an HTTPS proxy agent.
npm install axiosOr via CDN:
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>Use Axios proxy option to set protocol, host, and port. Example with AnonEdge:
import axios from 'axios';
const res = await axios({
url: 'https://example.com',
proxy: {
protocol: 'http',
host: 'gw.anonedge.com',
port: 823,
auth: { username: 'YOUR_USERNAME', password: 'YOUR_PASSWORD' }
}
});
console.log(res.data);For HTTPS targets, you can supply an agent with credentials embedded:
import axios from 'axios';
import { HttpsProxyAgent } from 'https-proxy-agent';
const username = 'YOUR_USERNAME';
const password = 'YOUR_PASSWORD';
// Note the escaped template placeholders and backticks for display purposes
const agent = new HttpsProxyAgent(`http://${username}:${password}@gw.anonedge.com:823`);
const res = await axios.get('https://ip-api.com/', { httpsAgent: agent });
console.log(res.data);