Skip to content

Commit

Permalink
fix(#51): prevent wsod if axios error
Browse files Browse the repository at this point in the history
  • Loading branch information
Decipher committed Sep 8, 2023
1 parent 8ce7089 commit 38d717b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/components/DruxtFieldLayoutParagraphs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default {
mixins: [DruxtFieldMixin],
data: () => ({
paragraphs: undefined,
paragraphs: [],
}),
async fetch() {
Expand All @@ -38,8 +38,12 @@ export default {
href = href.replace(this.$druxt.settings.baseUrl, '')
}
const { data } = await this.$druxt.axios.get(href)
this.paragraphs = data.data
try {
const { data } = await this.$druxt.axios.get(href)
this.paragraphs = data.data
} catch(err) {
console.error(err.message, href)
}
},
computed: {
Expand All @@ -48,7 +52,7 @@ export default {
*
* @return {object[]}
*/
rootParagraphs: ({ paragraphs, isLayout }) => paragraphs.filter((o) => isLayout(o) || (!isLayout(o) && !(o.attributes.behavior_settings.layout_paragraphs || {}).parent_uuid)),
rootParagraphs: ({ paragraphs, isLayout }) => (paragraphs || []).filter((o) => isLayout(o) || (!isLayout(o) && !(o.attributes.behavior_settings.layout_paragraphs || {}).parent_uuid)),
},
methods: {
Expand Down

0 comments on commit 38d717b

Please sign in to comment.