diff --git a/TODO.md b/TODO.md index ed01c49..a2eea23 100644 --- a/TODO.md +++ b/TODO.md @@ -1,4 +1,5 @@ ## TODO +* General - fallbacks in case no api response * General - sort things by sort_order * General - page headings etc - use api * mailer diff --git a/pages/index.vue b/pages/index.vue index 391098c..97ee5b1 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -68,15 +68,25 @@ export default { }, mounted () { - if (this.bgImages.length > 1) { + if (this.bgImages.length > 0) { this.setNextIndex() this.showHeading = true } }, async asyncData({ $axios }) { - const { bgImages, taglines } = await $axios.$get('/api/v1/home') - return { bgImages, taglines} + try { + const { bgImages, taglines } = await $axios.$get('/api/v1/home') + if (bgImages.length < 1) { + throw new Error('bgImages empty') + } + return { bgImages, taglines } + } catch { + return { + bgImages: ['/img/default-home.jpg'], + taglines: [''], + } + } }, methods: { diff --git a/static/img/default-home.jpg b/static/img/default-home.jpg new file mode 100644 index 0000000..c47b903 Binary files /dev/null and b/static/img/default-home.jpg differ