Cannot read property 'getByUID' of undefined error when trying to query by uid

Hi Community,

I am trying to query a document using the $prismic object $prismic.client.getByUID(uid, type), however I keep getting an error. I assume I must be missing an import somewhere?

I have installed the @prismicio/vue dependency (which seems to also include prismic-javascript & prismic-dom)

Am I missing something?

Cheers,
Patrick

P.S. In your documentation you have it listed as $prismic.client.getByUID(uid, type) however in your example, it seems to follow type and THEN uid const document = await $prismic.client.getByUID('page', params.uid)

Hello Patrick,

Thanks for sharing the vue dependency document, we need to update this. Have you installed the @nuxtjs/prismic dependency too?
Can you please try to change your query to $prismic.api.getByUID(type, uid).

Let me know after trying this query.

Priyanka

Hi Priyanka,

thanks for your response. It works now after using "$prismic.api.getByUID…" instead of "$prismic.client.getByUID".

Assuming this is the same for other users, this would of course be beneficial to update on your documentation (Query Content from the CMS with Nuxt.js - Prismic). In total, two issues seem to be present (please verify):

  1. "api" needs to be used instead "client"
  2. The documentation is showing the argument for the getByUID method in the wrong order.

Attaching a screenshot for reference.

Cheers,
Patrick

Hello Patrick,

Thanks for the feedback. We have updated our documentation.

Priyanka

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.