I have a very strange issue (or at least it looks strange to me) with AngularJS. On a simple controller I issue 2 independent requests to my NodeJS backend. Very often, one of the requests would end up being stuck in a pending state. Even stranger, sometimes, the response might switch in the sense that the response 1 that should go to request 1 goes to request 2. I can replicate this behavior both in my development environment and on a live production server (so there doesn't seem to be a server configuration issue). I suspect that the issue is with AngularJS, but I cannot seem to understand what it is.
Here is an overview of what I am doing:
appControllers.controller('DashboardController', ['$scope', '$http', function($scope, $http) {
$http.get('http://localhost:3001/api/report/top/2013-10-01/2013-10-07/10',{
headers: {
// Some header authentication
}
})
.success(function(response) {
// do some stuff
});
$http.get('http://localhost:3001/api/report/time/2013-10-01/2013-10-07/daily',{
headers: {
// Some header authentication
}
})
.success(function(response) {
// do some stuff
});
}]);Maybe it's worth mentioning that I am making CORS requests to an API server that is not under the same domain as the web application.
Please tell me what I am doing wrong, or how I could fix this issue (I do not want to chain the requests).
I have also tried using resources, with the same result :(
Thank you,
Cosmin
--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/j049M2Nlc3s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.