# Cannot read properties of undefined (reading 'lang') when trying to access project's detail

**URL:** <https://community.prismic.io/t/cannot-read-properties-of-undefined-reading-lang-when-trying-to-access-projects-detail/12610>\
**Category:** Developing with Prismic\
**Tags:** nuxtjs\
**Created:** [March 6, 2023, 2:02pm UTC](https://community.prismic.io/t/cannot-read-properties-of-undefined-reading-lang-when-trying-to-access-projects-detail/12610 "2023-03-06T14:02:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![quim\_ddv](https://avatars.discourse-cdn.com/v4/letter/q/da6949/32.png) [@quim\_ddv](https://community.prismic.io/u/quim_ddv)\
**Post date:** [March 6, 2023, 2:02pm UTC](https://community.prismic.io/t/cannot-read-properties-of-undefined-reading-lang-when-trying-to-access-projects-detail/12610/1 "2023-03-06T14:02:33Z")

</div>

¡Hello! I'm trying to make the projects detail work (/projecte/UID) but it won't work, it says "Cannot read properties of undefined (reading 'lang')". I don't know why is this happening, I hope someone can help me with this, thanks!

Heres my project's repository: [GitHub - quimzu/enricrojo.com](https://github.com/boira-studio/enricrojo.com)

---

<div class="post-metadata">

**Author:** ![jake](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/jake/32/5120_2.png) [@jake](https://community.prismic.io/u/jake)\
**Post date:** [March 6, 2023, 9:00pm UTC](https://community.prismic.io/t/cannot-read-properties-of-undefined-reading-lang-when-trying-to-access-projects-detail/12610/3 "2023-03-06T21:00:59Z")

</div>

Hi Dani 🙂

I've had a quick look at your repo and I can see the issue.

You've built your file structure up to have a route like `/projecte/uid`

But I noticed your routing inside the `/projectes/` path is using `'$route.fullPath+"/"+post.slugs[0]` which results in a `projectes/uid` expectation (projectes instead of projecte).

If I set this to:  
`<nuxt-link class="img_projecte" :to='"/projecte/"+post.slugs[0]'>`  
Then it correctly navigates through.

You'll need to match the pages folder path with the project path you've set. Or better yet use the [route resolver](https://prismic.io/docs/route-resolver) to handle your URL behaviour and use the [`prismic-link`](https://prismic.io/docs/nuxt-template-content#link-to-another-page) component instead of the `nuxt-link`.

I also noticed you're trying to pass a 'post' instead of 'page' into your store action for `load` but the function is expecting 'lang' and 'page' in the second argument.

```auto
async load (store, { lang, page = { alternate_languages: [] } }) {..

```

A quick fix for this is to set `page: post` in your dispatch event in projecte/uid

```auto
await store.dispatch('prismic/load', { lang, page: post })

```

Also `page = { alternate_languages: [] ` is possibly an issue as you're setting this as your default which is where your original lang query is coming from.

I'd advise in having your props either have correct default values or setting some conditionals on your values, this will help you debug a bit easier as the "Cannot read properties of undefined (reading 'lang')" is a bit of a red herring here, but still worth fixing.

For example you're checking if the first array item lang value equals es-es `v-if="alternateLanguages[0].lang == 'es-es'"` and if anything interrupts passing your alternativeLanguages prop value then it will default to an empty array and stop your conditional from being able to check the first item like you're doing above and fall over.

```auto
v-if="alternateLanguages.length && 'lang' in alternateLanguages[0] && alternateLanguages[0].lang == 'es-es'"

```

is one option/example. 🙂

Let me know how you get on

---

<div class="post-metadata">

**Author:** ![quim\_ddv](https://avatars.discourse-cdn.com/v4/letter/q/da6949/32.png) [@quim\_ddv](https://community.prismic.io/u/quim_ddv)\
**Post date:** [March 9, 2023, 12:02pm UTC](https://community.prismic.io/t/cannot-read-properties-of-undefined-reading-lang-when-trying-to-access-projects-detail/12610/4 "2023-03-09T12:02:34Z")

</div>

Thank you, it worked. Now I got another problem, and it is that when I change language using the LangSwitcher in /projecte/\_uid it redirects me to / instead of the same page. This problem only happens there for some reason.

---

<div class="post-metadata">

**Author:** ![Priyanka](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/priyanka/32/3223_2.png) [@Priyanka](https://community.prismic.io/u/Priyanka)\
**Post date:** [March 15, 2023, 1:11pm UTC](https://community.prismic.io/t/cannot-read-properties-of-undefined-reading-lang-when-trying-to-access-projects-detail/12610/5 "2023-03-15T13:11:42Z")

</div>

Hello @quim_ddv

You have to create language switcher described in this documentation here: [Internationalization with Nuxt - Documentation - Prismic](https://prismic.io/docs/nuxt-multilingual-templating#create-a-language-switcher)
