Need to get System IP Address from angularjs code.
I have searched in google. Everyone are suggesting third party from js.
So i dont want to make a call to get IP?
Is there any way to get IP from angularjs?
My actual scenario is.
Need to send system ip in every rest call
Use the location service at freegeoip.net
angular.module("myApp",[]).run(function($rootScope, $http) {
var url = "//freegeoip.net/json/";
$http.get(url).then(function(response) {
console.log(response.data.ip);
$rootScope.ip = response.data.ip;
});
});
<script src="https://unpkg.com/angular/angular.js"></script>
<div ng-app="myApp">
IP address = {{ip}}
</div>
This API endpoint is deprecated and will stop working on July 1st, 2018. For more information please visit: https://github.com/apilayer/freegeoip#readme"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With