()
| 55 | |
| 56 | // Example with fetch API |
| 57 | async function fetchWithSocks5Example () { |
| 58 | console.log('\n=== Fetch with SOCKS5 Proxy Example ===') |
| 59 | |
| 60 | try { |
| 61 | const socks5Proxy = new Socks5Agent('socks5://localhost:1080') |
| 62 | |
| 63 | const response = await fetch('http://httpbin.org/json', { |
| 64 | dispatcher: socks5Proxy |
| 65 | }) |
| 66 | |
| 67 | console.log('Status:', response.status) |
| 68 | const data = await response.json() |
| 69 | console.log('JSON data:', data) |
| 70 | |
| 71 | await socks5Proxy.close() |
| 72 | } catch (error) { |
| 73 | console.error('Error:', error.message) |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | // Example with HTTPS |
| 78 | async function httpsWithSocks5Example () { |
no test coverage detected