如何獲取用戶IP並將其發送到帖子請求中?在發帖請求中角度發送用戶IP
.controller('LinkCtrl', function($scope, $http){
$http.get("http://ipinfo.io").then(function(response){
$scope.userIp = response.data
})
$scope.onClickLink = function($event){
$http.post('http://localhost:7000/api/message',
{
ip: userIp.ip
})
}
})
我嘗試賽斯:的ReferenceError:USERIP沒有定義
'ip:$ scope.userIp.ip' – Sravan