"No documents were returned" while developing in local env

"No documents were returned"

What's missing? I didn't set up prismic and nextjs for this repo (so I'm learning about it) but now I have to extend it.

I have published a document to the prismic site, see below

I have created the a new custom-type and slices, and pushed those to Prismic (I am logged in on the command line)

I have declared a path for the page, in my local env version of the repo.

Routing:

const routes: prismic.ClientConfig["routes"] = [
	{
		type: "page",
		path: "/:uid",
	},
	{
		type: "page",
		uid: "home",
		path: "/",
	},
	{
		type: "page",
		uid: "purchase",
		path: "/purchase",
	},
	{
		type: "close_transaction",
		uid: "close-purchase",
		path: "/purchase/close-transaction",
	},
];

As a nextjs project, I have created a file in the /pages folder that maps to the component that I want to use to render this document.

So I summon the document for the component using getStaticProps

export const getStaticProps: GetStaticProps<Props> = async ({ locale, previewData }) => {
	const client = createClient({ previewData });
	// const page = await client.getByUID("close_transaction", "close-purchase", { lang: locale });
        // const page = await client.getSingle("close_transaction")
	const page = await client.getByUID("close_transaction", "close-purchase")

	return {
		props: { page },
		revalidate: ONE_HOUR_IN_SECONDS,
	};
};

And it says "No documents were returned". Separately the getSingle call works fine, so its either pulling that from the model.json in my local repo or from the template pushed up to Prismic.

So....

Is the document in Prismic.io accessible? I am meant to actually define development documents locally? I feel like I must be missing something incredibly fundamental to all of this, why isn't this easily debuggable?

Hello @greg2,

Welcome to Prismic community, and thanks for reaching out to us!

I suspect the error is happening because you're using a UID value that doesn't exist on any document. Can you check your document and confirm that you used the correct UID value in your data-fetching method?

Thanks,
Racheal.

Where do I find the UID?

Is it the slug in the metadata?

The project has an existing functioning custom-type, page. As a work around, I have just added all my new slices to that, and created a new document with a page custom type and a purchase slug, and it works as expected.

My prior document didn't work; with close_transaction custom type and a slug close-purchase (which seem to match the line that I was previously using to query prismic const page = await client.getByUID("close_transaction", "close-purchase")

So if the slug is the UID, then I still don't know what was the problem, unless there are rules about the UID (like no special characters??) that I am having problems with.

Hello @greg2,

You can find the UID value in your document; It could be the slug value because it's a common name used for the UID field.

From the screenshot you shared above, I can see that the name is close-purchase, but the UID value might not be the same.

Could you share the URL of your repository with me so I can do a check on my end? You can send it via DM if you prefer.

Thanks,
Racheal.

Yes, I matched the UID to the slug in the document for that custom type.

But have now archived that document and not experimenting with adding any other custom types because it Prismic doesn't seem reliable enough. We have a sole custom type (page) that I'm just going to push all the slices into, and that is allowing me to progress. Thanks for your time

Hello @greg2,

You could share your repository URL with me so I can take a look on my end and have a better understanding to provide more assistance to you. You can send it via DM if you prefer.

And also, let me know if you have further questions.

Thanks,
Racheal.