afterStoreSetup: Handle 404 cases.

This commit is contained in:
lain 2019-03-13 12:41:39 +01:00
parent 446785ddce
commit 48ac96cfc7

View file

@ -7,6 +7,7 @@ import App from '../App.vue'
const getStatusnetConfig = async ({ store }) => { const getStatusnetConfig = async ({ store }) => {
try { try {
const res = await window.fetch('/api/statusnet/config.json') const res = await window.fetch('/api/statusnet/config.json')
if (res.ok) {
const data = await res.json() const data = await res.json()
const { name, closed: registrationClosed, textlimit, uploadlimit, server, vapidPublicKey } = data.site const { name, closed: registrationClosed, textlimit, uploadlimit, server, vapidPublicKey } = data.site
@ -29,6 +30,9 @@ const getStatusnetConfig = async ({ store }) => {
} }
return data.site.pleromafe return data.site.pleromafe
} else {
throw (res)
}
} catch (error) { } catch (error) {
console.error('Could not load statusnet config, potentially fatal') console.error('Could not load statusnet config, potentially fatal')
console.error(error) console.error(error)
@ -38,7 +42,11 @@ const getStatusnetConfig = async ({ store }) => {
const getStaticConfig = async () => { const getStaticConfig = async () => {
try { try {
const res = await window.fetch('/static/config.json') const res = await window.fetch('/static/config.json')
if (res.ok) {
return res.json() return res.json()
} else {
throw (res)
}
} catch (error) { } catch (error) {
console.warn('Failed to load static/config.json, continuing without it.') console.warn('Failed to load static/config.json, continuing without it.')
console.warn(error) console.warn(error)