I am trying to create a blog with Next js but the getSingle ( getFirst precisely ) does not return any documents despite having the custom type and path set correctly.
I tried to dig a bit. When I tried to fetch from the query built by BuildQueryURL inside @prismicio/client it returned a JSON object but with an empty results field. And that's where the problem begins.
Where am I going wrong?
Welcome to the Prismic community forum.
There might be some reason I can think of getting the error:
- You might not publish the documents related to Custom Type in Prismic UI.
- The API ID of the Custom type needs to be corrected.
- How did you initiate
createClient() function? Could you paste the
prismic.io file code too?
- You are not passing previewData in
createClient() is provided the previewData object from
getStaticProps(). This enables Prismic's preview support. Check the example here.
Please check all these above if it still needs to be fixed, I need your repo name and project code.
Thanks for replying.
Just as you said I passed previewData to createClient and it returned an "invalid repository provided" error. So, I console logged and it seems the getRepositoryEndpoint function inside @prismic/createClient is not able to fetch the name of the repository, so I hardcoded it and it worked as it should.
You can see in the above SS the URL has undefined in place of the repo name.
But It shows the right repository elements in the local server while running slicemachine. I am not really sure what is causing this error.
This should not be expected behavior. I won't be able to help you without seeing your project source code. Please provide the Zip file or GitHub repo.