fix deprecation warning

This commit is contained in:
MTRNord 2017-08-13 00:56:37 +00:00
parent 02217c8bd2
commit 4a1ba01f44

View file

@ -231,35 +231,30 @@ 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});
}
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) => {
let response_return = {};
request(
{ method: "GET", url: langPath },
(err, response, body) => {
if (err || response.status < 200 || response.status >= 300) {
reject({err: err, response: response});
}
resolve(JSON.parse(body));
}
deferred.resolve(JSON.parse(body));
}
);
return deferred.promise;
);
});
}