forked from oxylabs/rotating-proxies-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttp_https_workaround.js
More file actions
19 lines (19 loc) · 824 Bytes
/
Copy pathhttp_https_workaround.js
File metadata and controls
19 lines (19 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
var axios = require("axios");
const HttpsProxyAgent = require("https-proxy-agent");
const httpsAgent = new HttpsProxyAgent({host: "46.138.246.248", port: 8088, auth: "USERNAME:PASSWORD"})
// Use axios as you normally would, but specify httpsAgent in the config, this is due to a bug
// with using an http proxy with an https target (https://github.com/axios/axios/issues/925#issuecomment-513028175)
axios = axios.create({httpsAgent});
// Create and execute a new Promise
(async function () {
try {
const url = `https://ip.oxylabs.io/`;
// Call the GET method on the URL with proxy information
let response = await axios.get(url);
// Print effective IP address
console.log(response.data);
} catch (err) {
//Log the error message
console.error(err);
}
})();