JavaScript: how to get the client IP address

JavaScript: how to get the client IP address

In this article we will see how to get the client IP address with JavaScript.

In this article we will see how to get the client IP address with JavaScript.

We can use the ifconfig.me service APIs like so:

'use strict';

const getIPAddress = () => {

    fetch('https://ifconfig.me/all.json').then(response => response.json())
    .then(res => { console.log( res.ip_addr ); });
};