update: fallback if no/emptyapi response

This commit is contained in:
ManjaroOne666 2019-02-14 11:36:23 +00:00
parent 28a561dac0
commit 3c8fb01df9
3 changed files with 14 additions and 3 deletions

View File

@ -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

View File

@ -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 }) {
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: {

BIN
static/img/default-home.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 KiB