AIA.factory('AuthenticationService', function ($http, $q) { return { authenticateUser: function (userInfo) { var deferred = $q.defer(); $http.post('http://localhost:95/API/api/Authenticate', JSON.stringify(userInfo), { headers: { 'Content-Type': 'application/json' } }) .success(function (data, status, headers, config) { console.log('success') deferred.resolve(data); }).error(function (data, status, headers, config) { console.log('error') deferred.reject(status); }); return deferred.promise; } } });