i am getting response with empty string.
shivwork opened this issue · comments
Code
iplocation('14.140.116.138').then((res) => {
console.log('res :->', res);
});
Console
res = {
country: '',
...
}
Hey @shivwork thanks for raising this. I have tested with the latest versions in 6.x
, 5.x
and 4.x
branches and cannot replicate. This can happen if there isn't a value from the IP metadata provider, but for this particular IP address all the data is there. I could also have been a temporary issue with the provider at the time. If this issue persists, please let me know and could you also include the output of DEBUG=iplocation node {your_script_name}.js
which will include information about what providers the module tried, what responses it got, etc.
I am also getting empty response.
@roryrjb can you help me please ?
@ntk860 if you are able to share a snippet of the code you are using and ideally the IP address so I can properly test this then that would be good, otherwise if you could tell me what fields are empty.
iplocation('56.70.97.8').then((res) => {
// res is empty
console.log(res)
})
.catch(error => {
console.log(error)
})
})
{ country: '',
countryCode: '',
region: '',
regionCode: '',
city: '',
postal: '',
ip: '',
latitude: null,
longitude: null,
timezone: '' }
@roryrjb thank you for trying to help
We we're seeing this too and were able to get non-empty results again by reversing the list of providers we found at https://github.com/roryrjb/iplocation/blob/master/src/index.ts#L6
So that our client code looks like this
const providers = [
'https://ipinfo.io/*',
'https://ipapi.co/*/json/',
];
const result = await iplocation(ipAddress, providers);
My guess is something changed at ipapi.co recently
@wtfleming thanks for pointing this out. I reached a similar fix when looking at this but wanted to get a more permanent solution in place, it seems like we may not be able to continue relying on ipapi.co, so will look for some alternatives. @ntk860 if you are able to implement something similar to this fix I think it'll be the best short term solution.
iplocation('90.254.60.95', [], callback);
Return an empty record as experienced by #16 (comment).
iplocation(
'90.254.60.95',
[
'https://ipinfo.io/*',
'https://ipapi.co/*/json/'
],
callback
);
Returns a proper record as suggested by #16 (comment)
https://ipapi.co/90.254.60.95/json/ returns:
"{\"error\": true, \"reason\": \"RateLimited\", \"message\": \"Sign up for IP Address Location API @ https://ipapi.co\"}"
then in
try {
log("got: " + body);
json = JSON.parse(body);
}
catch (ex) {
return retry(++i, callback);
}
JSON.parse passes, so return retry(++i, callback);
is not executed.
You need to throw an error or return retry(++i, callback);
in the try block if json.error exists.