Skip to content

Commit

Permalink
$http already returns a promise
Browse files Browse the repository at this point in the history
No need to wrap in an extra deferred :)
  • Loading branch information
0x-r4bbit committed Jul 20, 2014
1 parent caedace commit 20435ee
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions app/owm-library.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,20 @@ angular.module('owmLibrary', [])
.factory('owmUSCities', ['$http', '$q', 'OWM_CITIES_JSON_FILE',
function($http, $q, OWM_CITIES_JSON_FILE) {
return function() {
var defer = $q.defer();
$http.get(OWM_CITIES_JSON_FILE, { cache : true })
return $http.get(OWM_CITIES_JSON_FILE, { cache : true })
.success(function(cities) {
defer.resolve(cities);
});
return defer.promise;
}
}])

.factory('owmRequest', ['$http', '$q', 'OWM_API_PREFIX',
function($http, $q, OWM_API_PREFIX) {
return function(path) {
var defer = $q.defer();
$http.get(OWM_API_PREFIX + path)
return $http.get(OWM_API_PREFIX + path)
.success(function(data) {
defer.resolve(data);
})
return defer.promise;
});
}
}])

Expand Down

0 comments on commit 20435ee

Please sign in to comment.