On the server side of my ASP.net MVC application, I have a method that looks like this:
[HttpGet]
public JsonResult GetTrenings(string treningId)
{
var tempId = Guid.Parse(treningId);
var trening = TreningService.GetTreningById(tempId);
_trenings = TreningService.GetAllTreningsForUser(trening.UserId);
return Json(_trenings, JsonRequestBehavior.AllowGet);
}
I also have an Angular service :
publicApp.angularModule.factory('feedSingleTreningService', function ($q, $http) {
return {
getTrenings: function (data) {
var input = $http.get("/Feed/GetTrenings", { params: { treningId: data } });
var deferred = $q.defer();
deferred.resolve(input);
return deferred.promise;
},
};
});
And in my Controller, I call this service in this way:
feedSingleTreningService.getTrenings(data).then(function(results) {
console.log("test", results);
});
However, nothing is shown in the console. I've debugged the server-side code and confirmed that the request reaches it and returns _trenings. The service also returns a promise, but nothing seems to happen.
I tried changing "then" to "finally", and while "test" was displayed in the console, the results were undefined.
What could be causing this issue?