Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Fix deprecation warning about promise.defer() #1292

Merged
merged 3 commits into from
Aug 24, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 22 additions & 26 deletions src/languageHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,35 +231,31 @@ export function getCurrentLanguage() {
}

function getLangsJson() {
const deferred = Promise.defer();

request(
{ method: "GET", url: i18nFolder + 'languages.json' },
(err, response, body) => {
if (err || response.status < 200 || response.status >= 300) {
deferred.reject({err: err, response: response});
return;
return new Promise((resolve, reject) => {
request(
{ method: "GET", url: i18nFolder + 'languages.json' },
(err, response, body) => {
if (err || response.status < 200 || response.status >= 300) {
reject({err: err, response: response});
return;
}
resolve(JSON.parse(body));
}
deferred.resolve(JSON.parse(body));
}
);
return deferred.promise;
);
});
}

function getLanguage(langPath) {
const deferred = Promise.defer();

let response_return = {};
request(
{ method: "GET", url: langPath },
(err, response, body) => {
if (err || response.status < 200 || response.status >= 300) {
deferred.reject({err: err, response: response});
return;
return new Promise((resolve, reject) => {
request(
{ method: "GET", url: langPath },
(err, response, body) => {
if (err || response.status < 200 || response.status >= 300) {
reject({err: err, response: response});
return;
}
resolve(JSON.parse(body));
}

deferred.resolve(JSON.parse(body));
}
);
return deferred.promise;
);
});
}