Created
February 12, 2015 17:35
-
-
Save chrisbodhi/e28a96e16342a372f5f5 to your computer and use it in GitHub Desktop.
An Angular factory to retrieve the user's IP address
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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