Kod:
<!DOCTYPE html><html>
    <head>


    </head>
        <script>
            window.onload = function(){

                var r = new XMLHttpRequest();
                r.onreadystatechange = function(){
                    if(r.readyState == 4 && r.status == 200){
                        console.log(JSON.stringify(r.response));
                    }
                }
                r.open("GET", "https://api.ipify.org/", true);
                r.send();
            };
        </script>

    <body>
        
    </body>


 </html>