I'm using angular to make an AJAX call to my own REST API.
$scope.authenticate = function() {
$http({
headers: httpHeaders,
url: '/something/',
method: "POST",
data: { 'userId' : $scope.userId, 'password': $scope.password },
cache: false
})
.success(function(response, status) {
console.log(response);
var ourstring = JSON.stringify(response);
console.log(ourstring);
$scope.authenticate_data = response;
$scope.sessionId = response.sessionId;
$scope.cookie = response.cookie;
$scope.message = "You have successfully authenticated."
});
}
Somehow, angular incorrectly parses integers, and in the Chrome inspector's network tab, the call shows the following:
REQUEST TAB
{"sessionId": 115053508782199126, "cookie": "JSESSIONID=E61DD3443AE9E119060A637CF039936B; Path=/webservice"}
PREVIEW TAB (value stored in scope)
{"sessionId":115053508782199120,"cookie":"JSESSIONID=E61DD3443AE9E119060A637CF039936B; Path=/webservice"}
When I wrap the integer as a string in the backend, everything is fine. However, I really want to get understand what is causing this error.
Related link: Angular $resource does not parse correctly an integer response