# Generate: \[error\] Cannot read property 'data' of undefined

**URL:** <https://community.prismic.io/t/generate-error-cannot-read-property-data-of-undefined/2385>\
**Category:** Developing with Prismic\
**Tags:** nuxtjs\
**Created:** [October 22, 2020, 12:50pm UTC](https://community.prismic.io/t/generate-error-cannot-read-property-data-of-undefined/2385 "2020-10-22T12:50:24Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![maxvdschee](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@maxvdschee](https://community.prismic.io/u/maxvdschee)\
**Post date:** [October 22, 2020, 12:50pm UTC](https://community.prismic.io/t/generate-error-cannot-read-property-data-of-undefined/2385/1 "2020-10-22T12:50:24Z")

</div>

Hello,

I have a problem with the `apiOptions.routes` in the Prismic module.

In our project we have childeren under **expertises** which has a child that has a different layout called **data-en-customer-intelligence (DCI)**. The first part of the DCI page has `data` which gets picked up by `/services/expertises/:uid` and ends up generating an error in the build and outputting a page without content.

Running `"@nuxtjs/prismic": "^1.2.4",`

nuxt.config.js

```
prismic: {
	...
	apiOptions: {
		routes: [
			...
			{
				type: 'expertise',
				path: '/services/expertises/:uid',
			},
			{
				type: 'expertise_dci',
				path: '/services/expertises/data-en-customer-intelligence/:uid',
			},
		],
	},
},

```

---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [October 22, 2020, 2:14pm UTC](https://community.prismic.io/t/generate-error-cannot-read-property-data-of-undefined/2385/3 "2020-10-22T14:14:08Z")

</div>

Hi Max,

I'm not quite sure how the page giving the error `Cannot read property 'data' of undefined` could be related to the route resolver in this case. Can you explain further or better yet share the code for the page which is not building correctly?

Thanks.

---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [October 30, 2020, 12:21pm UTC](https://community.prismic.io/t/generate-error-cannot-read-property-data-of-undefined/2385/4 "2020-10-30T12:21:54Z")

</div>

This issue has been closed due to inactivity. [Flag to reopen](https://community.prismic.io/t/re-open-a-thread/2175).

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/system/32/1746_2.png) [@system](https://community.prismic.io/u/system)\
**Post date:** [April 9, 2021, 8:45am UTC](https://community.prismic.io/t/generate-error-cannot-read-property-data-of-undefined/2385/5 "2021-04-09T08:45:06Z")

</div>



---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [April 9, 2021, 8:52am UTC](https://community.prismic.io/t/generate-error-cannot-read-property-data-of-undefined/2385/6 "2021-04-09T08:52:08Z")

</div>

re-opened for @maxvdschee

---

<div class="post-metadata">

**Author:** ![maxvdschee](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@maxvdschee](https://community.prismic.io/u/maxvdschee)\
**Post date:** [April 9, 2021, 8:59am UTC](https://community.prismic.io/t/generate-error-cannot-read-property-data-of-undefined/2385/8 "2021-04-09T08:59:34Z")

</div>

He, I have updated the repo on github, there are now two instances where it happens:

```auto
{
	type: 'at_work',
	path: '/actueel/at-work/:uid',
},
{
	type: 'expertise_dci',
	path: '/services/expertises/data-en-customer-intelligence/:uid',
}

```

It seems to not like the `-` part but only if it's a repeatable type

for the single type page `over-ons` it has no problem with the `-` in the url.

hope this helps.

Cheers!

---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [April 9, 2021, 9:46am UTC](https://community.prismic.io/t/generate-error-cannot-read-property-data-of-undefined/2385/9 "2021-04-09T09:46:10Z")

</div>

Does the page structure of the 'pages' directory reflect the path that you have defined here?

---

<div class="post-metadata">

**Author:** ![maxvdschee](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@maxvdschee](https://community.prismic.io/u/maxvdschee)\
**Post date:** [April 12, 2021, 3:41am UTC](https://community.prismic.io/t/generate-error-cannot-read-property-data-of-undefined/2385/10 "2021-04-12T03:41:20Z")

</div>

Yes, it's defined the same way

---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [April 12, 2021, 9:11am UTC](https://community.prismic.io/t/generate-error-cannot-read-property-data-of-undefined/2385/11 "2021-04-12T09:11:41Z")

</div>

Can you share with me your project code so I can help debug this?

---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [April 19, 2021, 4:56pm UTC](https://community.prismic.io/t/generate-error-cannot-read-property-data-of-undefined/2385/13 "2021-04-19T16:56:22Z")

</div>

Hey Max,

I deployed your project on Netlify and had no issues with the route:

> **[Customer Intelligence | theFactor.e](https://607db552c0280a008dee8f4c--nostalgic-noether-e1c898.netlify.app/services/expertises/data-en-customer-intelligence/customer-intelligence/)**
>
> Customer Intelligence, ook wel UX (User eXperience) research genoemd, is het verzamelen, analyseren en gebruiken van klantgegevens met als doel om klanten beter te begrijpen. Met de verkregen inzichten is het mogelijk om een betere en effectievere...

---

<div class="post-metadata">

**Author:** ![maxvdschee](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@maxvdschee](https://community.prismic.io/u/maxvdschee)\
**Post date:** [April 20, 2021, 6:42am UTC](https://community.prismic.io/t/generate-error-cannot-read-property-data-of-undefined/2385/14 "2021-04-20T06:42:55Z")

</div>

He Phil,

I see that page is indeed working, it still produces an error in the build step which is fine for now.

CI build log:

```auto
...
[error] Cannot read property 'data' of undefined
  at asyncData (pages/services/expertises/_uid.js:3865:24)
  at runMicrotasks (<anonymous>)
  at processTicksAndRejections (internal/process/task_queues.js:97:5)
...
[error] Error generating route "/services/expertises/data": Page not found
...
[success] Generated route "/services/expertises/data-en-customer-intelligence/online-marketing"
[success] Generated route "/services/expertises/data-en-customer-intelligence/data-intelligence"
[success] Generated route "/services/expertises/data-en-customer-intelligence/customer-intelligence"

```

So if we take a look at the `actueel` page the second item in the list should have an url like: `.../actueel/at-work/at-work-max/`

but the url is `.../actueel/at`

Local build log:

```auto
...
Error generating route "/actueel/at": This page could not be found   

```

This is something that I can not fix and doesn't build a page that is still workable.

---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [April 20, 2021, 10:59am UTC](https://community.prismic.io/t/generate-error-cannot-read-property-data-of-undefined/2385/15 "2021-04-20T10:59:56Z")

</div>

OK, Thanks for pointing this out, I see these errors now.

You'll be happy to learn I spent more than an hour trying to figure out why `/actueel/at-work/at-work-max/` wasn't working instead of `/actueel/at-work/max-at-work/` 🤦‍♂️ 😂

I then spent more time looking in to this and I don't think the issue is coming from the route resolver, as the route resolver doesn't really have anything to do here since there are no dynamic page folders in the `/actueel/at-work/max-at-work/` route. For a route like this, since there are no dynamic folders, it's enough to use the link resolver.

The actual generation of that route is handled by Nuxt, which it seems is failing on that folder name because of the hyphen '-' like you suggested. If you remove this from the route resolver the same error occurs. I also noticed you were still you using the plugins 'Static' and 'Crawler' these are unnecessary as this is done by Nuxt now as I mentioned above. I removed these plugins, but no joy on the issue.

So to me, it seems like the issue is coming from either the `nuxt` or `@prismic/nuxt` plugins. I'm going to bring this up with the team and see what I can figure out about the issue.

---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [April 20, 2021, 11:06am UTC](https://community.prismic.io/t/generate-error-cannot-read-property-data-of-undefined/2385/16 "2021-04-20T11:06:22Z")

</div>

Issue: [Folders with hyphens '-', causing the route generation to fail. · Issue #136 · nuxt-community/prismic-module · GitHub](https://github.com/nuxt-community/prismic-module/issues/136)

---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [April 20, 2021, 12:36pm UTC](https://community.prismic.io/t/generate-error-cannot-read-property-data-of-undefined/2385/17 "2021-04-20T12:36:18Z")

</div>

@maxvdschee My bad it does indeed seem to work with the just link resolver [https://nostalgic-noether-e1c898.netlify.app/actueel/at-work/max-at-work](https://nostalgic-noether-e1c898.netlify.app/actueel/at-work/max-at-work)

One of the team thinks it's like you suggested an issue with how the apiOptions.routes option is processing that folder. The workaround now is just to use the linkresolver for this route and it should be fine. @lihbr Has created a ticket in the tracker about this.

---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [April 20, 2021, 12:45pm UTC](https://community.prismic.io/t/generate-error-cannot-read-property-data-of-undefined/2385/18 "2021-04-20T12:45:44Z")

</div>

OK, maybe this doesn't work as I thought 😂 Still investigating.

---

<div class="post-metadata">

**Author:** ![maxvdschee](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@maxvdschee](https://community.prismic.io/u/maxvdschee)\
**Post date:** [April 20, 2021, 1:04pm UTC](https://community.prismic.io/t/generate-error-cannot-read-property-data-of-undefined/2385/19 "2021-04-20T13:04:04Z")

</div>

Sorry my bad, should have checked better before posting, sorry for wasting your time 🙂

Yeah I tried a full upgrade and tried to remove those plugins but Indeed doesn't produce any better results.

I check the page, it does work with the hydrated version of the page but the static HTML is `page not found` content.

---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [April 20, 2021, 1:26pm UTC](https://community.prismic.io/t/generate-error-cannot-read-property-data-of-undefined/2385/20 "2021-04-20T13:26:42Z")

</div>

OK, so it should work using just the linkresolver, in fact since none of your routes have dynamic folder names the link resolver is all you need right now.

Can you explain a little further what you mean by this?

> [@maxvdschee](#):
>
> I check the page, it does work with the hydrated version of the page but the static HTML is `page not found` content.

---

<div class="post-metadata">

**Author:** ![maxvdschee](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@maxvdschee](https://community.prismic.io/u/maxvdschee)\
**Post date:** [April 20, 2021, 1:43pm UTC](https://community.prismic.io/t/generate-error-cannot-read-property-data-of-undefined/2385/22 "2021-04-20T13:43:38Z")

</div>

Okay I will try that.

On the page [https://nostalgic-noether-e1c898.netlify.app/actueel/at-work/max-at-work](https://nostalgic-noether-e1c898.netlify.app/actueel/at-work/max-at-work) it showed before It couldn't find the page but that has been resolved now.

If you look at the source version `view-source:https://nostalgic-noether-e1c898.netlify.app/actueel/at-work/max-at-work` none of the meta and content is showing up in the generated version and just has the default loader of nuxt in body. this should be generated content from that page.

---

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [April 20, 2021, 4:10pm UTC](https://community.prismic.io/t/generate-error-cannot-read-property-data-of-undefined/2385/23 "2021-04-20T16:10:16Z")

</div>

I see that. It must be to do with how it's deployed, because locally everything is built correctly.

 ![Screenshot 2021-04-20 at 18.08.57](https://europe1.discourse-cdn.com/flex013/uploads/prismic/original/2X/0/09d27038097a0dd6519c75e74b1b5b9af817671b.png)

Have you tried going full static?

> **[Going Full Static](https://nuxtjs.org/blog/going-full-static/)**
>
> Long awaited features for JAMstack fans has been shipped in v2.13: full static export, improved smart prefetching, integrated crawler, faster re-deploy, built-in web server and new target option for config :zap:️

---

<div class="post-metadata">

**Author:** ![maxvdschee](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@maxvdschee](https://community.prismic.io/u/maxvdschee)\
**Post date:** [April 21, 2021, 4:49am UTC](https://community.prismic.io/t/generate-error-cannot-read-property-data-of-undefined/2385/24 "2021-04-21T04:49:28Z")

</div>

I have tried but the older crawler and static plugin didn't work with that, I will change it to the newest implementation and try out the full static version.

[Next page](https://community.prismic.io/t/generate-error-cannot-read-property-data-of-undefined/2385.md?page=2)
