Identifying the user location - (Office or Home)

39 Views Asked by At

While trying to capture IP address of the user visiting the webpage, I am trying to match the Ip address with the organization's CIDR range to confirm if the user is on the organization network or home network. I used below code to capture IP address, does it make sense to do it this way? Any suggestions?

  <script type="text/javascript">
 function getIP() {
  fetch('https://ipapi.co/json/')
    .then(response => response.json())
    .then(data => {
      alert(`Your IP address is ${data.ip}`);
    })
    .catch(error => console.error(error));
}

getIP();
  </script>  
0

There are 0 best solutions below