September 20, 2014
In one of my projects, I needed a reliable way to get a visitor's IP address and his location in Javascript, without a server. There is a wonderful thread on StackOverflow which gives a lot of solutions but when I tried them, they were either not working (400/500 errors) or not returning the data I needed.
So I decided it would be fun to write a small webservice to do just that: http://userinfo.io.
It's really simple to use: get the library from Github, insert it in your code and call the method:
UserInfo.getInfo(function (data, err) {
if (err) {
// Do something with the error
} else {
// Do something with the data
}
});
Check it out on Github and do not hesitate to send me your remarks!