1<script type="application/javascript">
2 function getIP(json) {
3 document.write("My public IP address is: ", json.ip);
4 }
5</script>
6
7<script type="application/javascript" src="https://api.ipify.org?format=jsonp&callback=getIP"></script>
1var http = require('http');
2
3http.get({'host': 'api.ipify.org', 'port': 80, 'path': '/'}, function(resp) {
4 resp.on('data', function(ip) {
5 console.log("My public IP address is: " + ip);
6 });
7});