Skip to content

Instantly share code, notes, and snippets.

@chrisbodhi
Created February 12, 2015 17:35
Show Gist options
  • Save chrisbodhi/e28a96e16342a372f5f5 to your computer and use it in GitHub Desktop.
Save chrisbodhi/e28a96e16342a372f5f5 to your computer and use it in GitHub Desktop.
An Angular factory to retrieve the user's IP address
app.factory( 'getIP', function ( $http ) {
'use strict';
var self = this;
return function getIP () {
self.ipCheck = 'http://ipinfo.io/json';
return $http.get(self.ipCheck)
.then(function (result){
return result;
})
.catch(function (status){
console.log(status);
return 'IP address is unknoooooown.';
});
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment