{"ip": "<nil>"} returned when supplying callback parameter
Hi,
When I hit the service with say
https://api.ipify.org/?format=jsonp
I get back as expected:
callback({"ip":"195.xxx.xxx.xxx"});
However if I add the "callback" parameter, for example
http://api.ipify.org/?format=jsonp&callback=jq
...then I get back:
jq({"ip":"\u003cnil\u003e"});
Why? Is this a bug?
I'm now trying to call it directly from script code with jQuery:
$.getJSON('//api.ipify.org?format=json', function(data) {
console.log("data: " + data);
console.log(JSON.stringify(data, null, 2));
});
This results in (in the console):
data: [object Object]
VM2301:8 {
"ip": "<nil>"
}
Is this somehow something I'm doing wrong?
I have now tried another service that seems to work correctly, which suggests this must be a bug perhaps. The following code works:
$.getJSON('//jsonip.com', function(data) {
x=document.getElementById("myDiv");
x.innerHTML = "Your IP is: <b>" + data.ip + "</b>";
console.log("IP: " + data.ip);
});
This results as expected in the console in:
IP: 195.xxx.xxx.xxx