Fix Promise.defer warnings in getconfig.js (#7409)

Signed-off-by: Aaron Raimist <aaron@raim.ist>
pull/7444/head
Aaron Raimist 2018-10-02 19:20:03 -05:00
parent b09aa2cff3
commit a5fb33de02
No known key found for this signature in database
GPG Key ID: 37419210002890EF
1 changed files with 26 additions and 28 deletions

View File

@ -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;
} }