update: fallback if no/emptyapi response
This commit is contained in:
parent
28a561dac0
commit
3c8fb01df9
1
TODO.md
1
TODO.md
|
@ -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
|
||||||
|
|
|
@ -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: {
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 194 KiB |
Loading…
Reference in New Issue