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 ## TODO
* General - fallbacks in case no api response
* General - sort things by sort_order * General - sort things by sort_order
* General - page headings etc - use api * General - page headings etc - use api
* mailer * mailer

View File

@ -68,15 +68,25 @@ export default {
}, },
mounted () { mounted () {
if (this.bgImages.length > 1) { if (this.bgImages.length > 0) {
this.setNextIndex() this.setNextIndex()
this.showHeading = true this.showHeading = true
} }
}, },
async asyncData({ $axios }) { async asyncData({ $axios }) {
try {
const { bgImages, taglines } = await $axios.$get('/api/v1/home') const { bgImages, taglines } = await $axios.$get('/api/v1/home')
if (bgImages.length < 1) {
throw new Error('bgImages empty')
}
return { bgImages, taglines } return { bgImages, taglines }
} catch {
return {
bgImages: ['/img/default-home.jpg'],
taglines: [''],
}
}
}, },
methods: { methods: {

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 KiB