mirror of https://github.com/vector-im/riot-web
Fix Promise.defer warnings in getconfig.js (#7409)
Signed-off-by: Aaron Raimist <aaron@raim.ist>pull/7444/head
parent
b09aa2cff3
commit
a5fb33de02
|
@ -33,8 +33,7 @@ export async function getVectorConfig(relativeLocation) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getConfig(configJsonFilename) {
|
function getConfig(configJsonFilename) {
|
||||||
let deferred = Promise.defer();
|
return new Promise(function(resolve, reject) {
|
||||||
|
|
||||||
request(
|
request(
|
||||||
{ method: "GET", url: configJsonFilename },
|
{ method: "GET", url: configJsonFilename },
|
||||||
(err, response, body) => {
|
(err, response, body) => {
|
||||||
|
@ -48,10 +47,10 @@ function getConfig(configJsonFilename) {
|
||||||
// from a file:// URI.
|
// from a file:// URI.
|
||||||
if (response) {
|
if (response) {
|
||||||
if (response.status == 404 || (response.status == 0 && body == '')) {
|
if (response.status == 404 || (response.status == 0 && body == '')) {
|
||||||
deferred.resolve({});
|
resolve({});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
deferred.reject({err: err, response: response});
|
reject({err: err, response: response});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,9 +58,8 @@ function getConfig(configJsonFilename) {
|
||||||
// parameter, since this throws a parse error on empty
|
// parameter, since this throws a parse error on empty
|
||||||
// which breaks if there's no config.json and we're
|
// which breaks if there's no config.json and we're
|
||||||
// loading from the filesystem (see above).
|
// loading from the filesystem (see above).
|
||||||
deferred.resolve(JSON.parse(body));
|
resolve(JSON.parse(body));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
})
|
||||||
return deferred.promise;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue