Home

Published

- 1 min read

node-fetch proxy

img of node-fetch proxy

The solution for this is noted below

node-fetch proxy

Solution

   // npm install node-fetch
// npm install https-proxy-agent

const fetch = require('node-fetch')
const HttpsProxyAgent = require('https-proxy-agent')

;(async () => {
	const proxyAgent = new HttpsProxyAgent('http://46.250.171.31:8080')
	const response = await fetch('https://httpbin.org/ip?json', { agent: proxyAgent })
	const body = await response.text()
	console.log(body)
})()

Try other methods by searching on the site. That is if this doesn’t work