fix(config): stop throwing on config.yml 404, fix manual init (#1801)

This commit is contained in:
Shawn Erquhart 2018-10-09 13:53:12 -04:00 committed by GitHub
parent b167b79fc6
commit d06c663778
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -56,10 +56,10 @@ function parseConfig(data) {
}
async function getConfig(file, isPreloaded) {
const response = await fetch(file, { credentials: 'same-origin' });
if (response.status !== 200) {
const response = await fetch(file, { credentials: 'same-origin' }).catch(err => err);
if (response instanceof Error || response.status !== 200) {
if (isPreloaded) return parseConfig('');
throw new Error(`Failed to load config.yml (${response.status})`);
throw new Error(`Failed to load config.yml (${response.status || response})`);
}
const contentType = response.headers.get('Content-Type') || 'Not-Found';
const isYaml = contentType.indexOf('yaml') !== -1;