Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to retrieve remote IP address in an Axios call from Node

I would like to get the resolved IP address of the remote url when I make an axios call in Node. See *** comment below. Thanks a lot in advance!

axios.get('http://www.example.com')
  .then(function (response) {
    // *** How can I get the resolved IP address of www.example.com here
  })
  .catch(function (error) {
    console.log(error);
  });
like image 993
Shadid Haque Avatar asked Oct 14 '25 18:10

Shadid Haque


1 Answers

The Axios documentation states response.request "is the last ClientRequest instance in node.js (in redirects)."

axios.get('http://www.example.com')
  .then(function (response) {
    console.log(response.request.socket.remoteAddress);
  });
like image 64
Chad N B Avatar answered Oct 17 '25 08:10

Chad N B



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!