axios-socks5-agent
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

axios-socks5-agent

npm i axios-socks5-agent

wrap for socks5-http-client and socks5-https-client. I wrote this because there is no module support socks5 for axios and allow modifying agentOptions (sth likes keepAlive)

const axios = require('axios')
const SocksAgent = require('axios-socks5-agent')

const { httpAgent, httpsAgent } = SocksAgent({
  agentOptions: {
    keepAlive: true,
  },
  // socks5
  host: '127.0.0.1',
  port: 9050,
  // socks5 auth
  username: 'admin',
  password: 'pass1234',
})

axios
  .get('http://wtfismyip.com/json', { httpAgent, httpsAgent })
  .then(res => console.log(res.data))
  .catch(e => console.error(e))

Usage

  • new Socks5Agent(options) => { httpAgent, httpsAgent }

  • httpAgent vs httpsAgent: axios config

Package Sidebar

Install

npm i axios-socks5-agent

Weekly Downloads

298

Version

1.0.5

License

ISC

Unpacked Size

2.85 kB

Total Files

5

Last publish

Collaborators

  • 0x0a0d