Fetch both config.json-s at the same time, first one fails 99% of the time
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
ffd155a6aa
commit
e669c681e2
|
@ -21,15 +21,19 @@ import request from 'browser-request';
|
||||||
export async function getVectorConfig(relativeLocation) {
|
export async function getVectorConfig(relativeLocation) {
|
||||||
if (relativeLocation === undefined) relativeLocation = '';
|
if (relativeLocation === undefined) relativeLocation = '';
|
||||||
if (relativeLocation !== '' && !relativeLocation.endsWith('/')) relativeLocation += '/';
|
if (relativeLocation !== '' && !relativeLocation.endsWith('/')) relativeLocation += '/';
|
||||||
|
|
||||||
|
const specificConfigPromise = getConfig(`${relativeLocation}config.${document.domain}.json`);
|
||||||
|
const generalConfigPromise = getConfig(relativeLocation + "config.json");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const configJson = await getConfig(`${relativeLocation}config.${document.domain}.json`);
|
const configJson = await specificConfigPromise;
|
||||||
// 404s succeed with an empty json config, so check that there are keys
|
// 404s succeed with an empty json config, so check that there are keys
|
||||||
if (Object.keys(configJson).length === 0) {
|
if (Object.keys(configJson).length === 0) {
|
||||||
throw new Error(); // throw to enter the catch
|
throw new Error(); // throw to enter the catch
|
||||||
}
|
}
|
||||||
return configJson;
|
return configJson;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return await getConfig(relativeLocation + "config.json");
|
return await generalConfigPromise;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue