Hi @wangac ,
There is no direct way available to get IP address of logged in user.
But there is a workaround that you can use that. You can call this free Api that will provide you logged in user IP address and few other details. Here is the URL: https://ipinfo.io/json.
You can call this Api once user is successfully logged in and save this information either in Dataverse or Local Storage as you wish. You can first try pasting above URL in your browser and you can see IP and other details.
To call this Api via JS, here is an example to use:
// Call Api to Get User's IP Address
fetch('https://ipinfo.io/json')
.then(response => response.json())
.then(data => {
// Pass the IP address to Liquid template or save in Dataverse/Local Storage
var userIp = data.ip;
})
.catch(error => console.error('Error fetching IP address:', error));
Hope this helps you. Feel free to share if you have any questions.
Thanks,
Saud
If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.