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() { function getLangsJson() {
const deferred = Promise.defer(); return new Promise((resolve, reject) => {
request(
request( { method: "GET", url: i18nFolder + 'languages.json' },
{ method: "GET", url: i18nFolder + 'languages.json' }, (err, response, body) => {
(err, response, body) => { if (err || response.status < 200 || response.status >= 300) {
if (err || response.status < 200 || response.status >= 300) { reject({err: err, response: response});
deferred.reject({err: err, response: response}); }
return; resolve(JSON.parse(body));
} }
deferred.resolve(JSON.parse(body)); );
} });
);
return deferred.promise;
} }
function getLanguage(langPath) { function getLanguage(langPath) {
const deferred = Promise.defer(); return new Promise((resolve, reject) => {
let response_return = {};
let response_return = {}; request(
request( { method: "GET", url: langPath },
{ method: "GET", url: langPath }, (err, response, body) => {
(err, response, body) => { if (err || response.status < 200 || response.status >= 300) {
if (err || response.status < 200 || response.status >= 300) { reject({err: err, response: response});
deferred.reject({err: err, response: response}); }
return; resolve(JSON.parse(body));
} }
);
deferred.resolve(JSON.parse(body)); });
}
);
return deferred.promise;
} }