diff --git a/nuxt.config.js b/nuxt.config.js index 087d30019d..f38919d6cc 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -12,15 +12,30 @@ export default { authorization: `Token ${process.env.AUTH_TOKEN}`, }, } - const talks = await axios.get( - `${DEFAULT_BASE_URL}/api/events/speeches/?event_types=talk,sponsored`, - config, - ) - const tutorials = await axios.get( - `${DEFAULT_BASE_URL}/api/events/speeches/?event_types=tutorial`, - config, - ) + const talks = await axios + .get( + `${DEFAULT_BASE_URL}/api/events/speeches/?event_types=talk,sponsored`, + config, + ) + .catch((error) => { + if (error.response.status === 404) { + return { data: [] } + } + }) + const tutorials = await axios + .get( + `${DEFAULT_BASE_URL}/api/events/speeches/?event_types=tutorial`, + config, + ) + .catch((error) => { + if (error.response.status === 404) { + return { data: [] } + } + }) const getAllDetailTalks = async () => { + if (!talks.data) { + return [] + } const data = await Promise.all( talks.data.map(async (talk) => { return await axios @@ -34,6 +49,9 @@ export default { return data } const getAllDetailTutorials = async () => { + if (!tutorials.data) { + return [] + } const data = await Promise.all( tutorials.data.map(async (tutorial) => { return await axios diff --git a/store/index.js b/store/index.js index 4562f400e3..e7c79f91a1 100644 --- a/store/index.js +++ b/store/index.js @@ -55,6 +55,7 @@ export const actions = { }, async $getSchedulesData({ commit }) { const { data } = await this.$http.$get('/api/events/schedule/') + if (!data) return commit('setSchedulesData', data) }, async $getKeynotesData({ commit }) {