There is a handy IP tracker at https://ipapi.co/json/. I want viewers of my website to see their IP address at the bottom of the webpage. What I have right now is:
<div class="container">
  <div id="IP">IP Address should show here.</div>
  <script>
    document.getElementById('IP').innerHTML = (https://ipapi.co/json/).ip;
  </script>
</div>
However, this doesn't display the IP address. I'm probably using the wrong approach. How do I get it to display correctly?
Edit: I tried doing:
<div class="container">
  <div id="IP">IP Address should show here.</div>
  <script>
    fetch('https://ipapi.co/json/')
      .then(function(response) {
        return response.json();
      })
      .then(function(myJson) {
        document.getElementById('IP').innerHTML = JSON.stringify(myJson.ip);
      });
  </script>
</div>
But that isn't working either.
 
     
     
     
     
    