No documents were returned | Next JS 14

I just started to fetch data from prismic cms nus it gives me Error: No documents were returned error.
Could you please help me to fix this?

It says that no documents are returned as I think you are passing not the right thing as ID param:

const page = await client.getByUID("career",
If you can console.log uid as why are you passing ?

I would say try to get the document first by passing the actual hardcoded ID, for example:
const page = await client.getByUID("career", "my-career-page-id") and see if you can receive the document.

You should name your dynamic route:
So the path to this page in your project is like:

And then you can simply get the uid param:

type Params = {
    uid: string;

export default async function CareerPage({params}: { params: Params }) {
    const client = createClient();
    const page = await client.getByUID('career', params.uid)
    // ... rest of the code

To get UID as param you also need to tell Next to generate params:

export async function generateStaticParams() {
    const client = createClient();
    const pages = await client.getAllByType('career')

    return => ({uid: page.uid});

If that's a single page type (unique page) you don't need UID and params, if it's a repeated page type, you will have to do as above. For single pages you can simply do

await client.getSingle('home_page')

To receive the document.

Everything is well described in the docs Fetch Data in Next.js - Documentation - Prismic :slight_smile: Just read them through and everything will become clear!


Thank you so much