ยฉ 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Cloudflare DevelopersCD
Cloudflare Developersโ€ข2y agoโ€ข
2 replies
DigitalDauber

How to trigger build fail

I am having an issue where a build completes successfully even when vital data is missing and makes the site unnavigable.

How do I trigger a build fail if fetch does not return a valid response?

Here is my Async Function:

async fetch() {
// Fetch the GlobalSettings object from Contentful,
// and if found bind it to a data prop
try {
const settingsPromise = this.$nacelle.client
.query({
query: ALLCONTENT,
variables: {
filter: {
handles: ['global-settings'],
type: 'globalSettings'
}
}
})
.then((res) => {
return res.data.allContent.edges[0].node
})

const menusPromise = this.$nacelle.client
.query({
query: ALLCONTENT,
variables: {
filter: {
type: 'menu',
first: 500
}
}
})
.then((res) => {
return res.data.allContent.edges.map((edge) => edge.node)
})

const [{ fields }, menus] = await Promise.all([
settingsPromise,
menusPromise
])
this.$store.commit('space/setMenus', menus)
const swatches = this.createColorCategories(fields?.colorSwatches)
this.initializeGlobalSettings(fields)
this.initializeColorCategories(swatches)
this.initCartMotivator()
} catch (e) {
console.warn(
No Global Settings entry found.
No Global Settings entry found.
)
}
},
Cloudflare Developers banner
Cloudflare DevelopersJoin
Welcome to the official Cloudflare Developers server. Here you can ask for help and stay updated with the latest news
85,042Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

cloudflare page fail build
Cloudflare DevelopersCDCloudflare Developers / general-help
2y ago
Page build failed
Cloudflare DevelopersCDCloudflare Developers / general-help
3y ago
Cloudflare Pages Build Failing
Cloudflare DevelopersCDCloudflare Developers / general-help
17mo ago
HEIC images fail to upload
Cloudflare DevelopersCDCloudflare Developers / general-help
5mo ago