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>