var requestOne = $http({
method: 'POST',
url: $rootScope.apisrvr + 'user/user_signin',
data: { username: $scope.user.username, password: $scope.user.password },
});
这是我的代码,当我写:console.log(requestOne);
我得到:
that
我只想得到$$state / value / data / salt
。但是,当我尝试console.log(requestOne.$$state.value.data.salt);
时,我收到错误TypeError: Cannot read property 'data' of undefined
。我如何从这里获得salt
?
答案 0 :(得分:1)
requestOne
是promise变量本身,要实际获得结果,您需要在promise的末尾添加.then
调用,如下所示:
var requestOne = $http({
method: 'POST',
url: $rootScope.apisrvr + 'user/user_signin',
data: { username: $scope.user.username, password: $scope.user.password },
}).then(function(result){
console.log(result);
});