PROXY IN NODEJS AXIOS

Asked

Viewed 451 times

-1

How do I put proxy on request in Xios? I’ve tried everything but I’m not getting it.

axios.post('localhost:3000', postdata, 
    {
        headers: headers
    },
    {
        proxy: 'http://minhaproxy:@proxy.crawlera.com:8010'
    })
    .then((res) => { 
        console.log("ok") 
    }

1 answer

2


Hello, good night friend! You did not put the proxy the right way, you should put inside the same JSON in which one finds the headers, getting like this:

axios.post('localhost:3000', postdata,
    {
        headers: headers,
        proxy: {
            host: 'http://minhaproxy:@proxy.crawlera.com',
            port: 8010
        }
    }
    .then((res) => {
        console.log("ok")
    }
  • Muti thanks, it worked here.

  • For nothing, if it is the correct answer, mark it as correct so that other people who have the same problem come here.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.