node.js 18.3 native fetch request with a proxy

Viewed 215

I would like to make a request with a proxy using native fetch node.js 18.3 but i have no idea how.

My code:

import proxyAgent from 'proxy-agent';

(async () => {
    const res = await fetch('https://api.ipify.org?format=json', {
        agent: new proxyAgent('http://80.48.119.28:8080'),
    });
    const data = await res.json();
    console.log(data); //it shows my ip
})();
0 Answers
Related