How to use axios to make an https call?
Axios https proxy support is borked if using https proxies. Try passing the proxy through [httpsProxyAgent][1]
using http.
var axios = require('axios'); let httpsProxyAgent = require('https-proxy-agent');var agent = new httpsProxyAgent('http://username:pass@myproxy:port');var config = { url: 'https://google.com', httpsAgent: agent}axios.request(config).then((res) => console.log(res)).catch(err => console.log(err))
Alternatively there is a fork of Axios that incorporates this: axios-https-proxy-fix but I'd recommend the first method to ensure latest Axios changes.
Try this. That work for me.
First
npm install axios-https-proxy-fix
Then
import axios from 'axios-https-proxy-fix'; const proxy = { host: 'some_ip', port: some_port_number, auth: { username: 'some_login', password: 'some_pass' }};async someMethod() { const result = await axios.get('some_https_link', {proxy});}
You can solve this problem looking this issue
At this solution instead use the proxy interface, use the http(s)Agent.For it the solution use the native node module https-proxy-agent
.
var ProxyAgent = require('https-proxy-agent');var axios = require('axios');const agent = ProxyAgent('http://username:pass@myproxy:port')var config = { url: 'https://google.com', proxy: false, httpsAgent: agent};
For it works the proxy property must be equal to false.