Skip to content

Commit e669c68

Browse files
committed
Fetch both config.json-s at the same time, first one fails 99% of the time
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
1 parent ffd155a commit e669c68

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎src/vector/getconfig.js‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,19 @@ import request from 'browser-request';
2121
export async function getVectorConfig(relativeLocation) {
2222
if (relativeLocation === undefined) relativeLocation = '';
2323
if (relativeLocation !== '' && !relativeLocation.endsWith('/')) relativeLocation += '/';
24+
25+
const specificConfigPromise = getConfig(`${relativeLocation}config.${document.domain}.json`);
26+
const generalConfigPromise = getConfig(relativeLocation + "config.json");
27+
2428
try {
25-
const configJson = await getConfig(`${relativeLocation}config.${document.domain}.json`);
29+
const configJson = await specificConfigPromise;
2630
// 404s succeed with an empty json config, so check that there are keys
2731
if (Object.keys(configJson).length === 0) {
2832
throw new Error(); // throw to enter the catch
2933
}
3034
return configJson;
3135
} catch (e) {
32-
return await getConfig(relativeLocation + "config.json");
36+
return await generalConfigPromise;
3337
}
3438
}
3539

0 commit comments

Comments
 (0)