summaryrefslogtreecommitdiffstats
path: root/js/app/Config.js
diff options
context:
space:
mode:
authorDaniel Schaal <daniel@schaal.email>2017-06-08 05:10:34 +0200
committerDaniel Schaal <daniel@schaal.email>2017-06-10 11:19:07 +0200
commit7cebc63defdd640b822132a1e24b489345ac06e9 (patch)
tree34fb03b39d0a2a472aae12f0c7eae2454834f63d /js/app/Config.js
parent2eddf6242be77e21a4a9d05b56dc9cc0125472c3 (diff)
Use regular promise for http calls
Diffstat (limited to 'js/app/Config.js')
-rw-r--r--js/app/Config.js27
1 files changed, 9 insertions, 18 deletions
diff --git a/js/app/Config.js b/js/app/Config.js
index 2152615c6..4df6c9b00 100644
--- a/js/app/Config.js
+++ b/js/app/Config.js
@@ -92,12 +92,10 @@ app.config(function ($routeProvider, $provide, $httpProvider) {
var oldestFirst = SettingsResource.get('oldestFirst');
var search = $location.search().search || '';
- var deferred = $q.defer();
-
// if those two values are null it means we did not receive
// the settings request from the server so dont query the server
if (showAll === null || oldestFirst === null) {
- deferred.resolve({});
+ return {};
} else {
var parameters = {
type: type,
@@ -125,16 +123,14 @@ app.config(function ($routeProvider, $provide, $httpProvider) {
}
}
- $http({
+ return $http({
url: BASE_URL + '/items',
method: 'GET',
params: parameters
- }).success(function (data) {
- deferred.resolve(data);
+ }).then(function (response) {
+ return response.data;
});
}
-
- return deferred.promise;
}
};
};
@@ -143,16 +139,15 @@ app.config(function ($routeProvider, $provide, $httpProvider) {
return {
sites: /* @ngInject */ function (
$http, $q, BASE_URL, $location, Publisher, SettingsResource) {
- var deferred = $q.defer();
-
// always use the code from the url
var language = $location.search().lang;
if (!language) {
language = SettingsResource.get('language');
}
- $http.get(BASE_URL + '/settings').then(function (data) {
- Publisher.publishAll(data);
+ return $http.get(
+ BASE_URL + '/settings').then(function (response) {
+ Publisher.publishAll(response.data);
// get url and strip trailing slashes
var url = SettingsResource.get('exploreUrl')
@@ -166,13 +161,9 @@ app.config(function ($routeProvider, $provide, $httpProvider) {
return $http.get(defaultExploreUrl);
});
- }).then(function (data) {
- deferred.resolve(data.data);
- }).catch(function () {
- deferred.reject();
+ }).then(function (response) {
+ return response.data;
});
-
- return deferred.promise;
}
};
};