WebpackError: TypeError: Cannot read property 'url' of undefined

Hi Prismic people, I encountered an issue while running build command.

WebpackError: TypeError: Cannot read property ‘url’ of undefined

I am using Gatsby and gatsby-source-prismic in this project.

<img src={node.data.thumbnail.url} alt="" />

I have no idea why url is undefined coz it’s already added in the query to a page where it needs to be displayed.

Running develop command has no issue.

Hi there,

Thank you for contacting us, I guess this issue is related to the way you are accessing Prismic content.

As you know Gatsby is a static website generator, and when building your website using gatsby-source-prismic plugin; your Gatsby project fetches your content from Prismic.

And if you don’t have a content available in your Prismic repository then your application breaks.

Here is an full exmaple of how to retrieve image link with Gatsby with the right validation, please notice the usage of if (!prismicContent) return null

Please let us know if that doesn’t answer your question,

Fares

Hey, thanks for your response.
Just figured out where the issue really came from using cypress and already managed to solve the issue.

Ok, thanks for letting us know.