API return Unpublished documents

Hi,

I have 15 published and 110 unpublished documents of type press_releases. When I do a Predicates::at('document.type', 'press_releases') query, it is return all 125 documents. Looks like it just started doing this today. Were there changes to the API ?

Hi @long. This is very strange. Can you send me the following so that I can investigate?

  • The url for your Prismic repository
  • The exact query that you’re running when you see this

If you don’t want to share this publicly here, then you can send it to me in a private message.

@long Hi, I just tested your API Browser and I’m only seeing the 16 documents that are published.

I can see that you have Release with bunch of Press Release documents. My guess is that you have a preview cookie set for that Release. Can you try to clear your cookies and see if you are still getting the same results?

@team-education, the query is returning only published Press Release documents now. I don't understand the issue with the preview cookie. I'm executing the query on the server side so how does the cookie come into play ? Thanks.

@long Well depending on how you've set things up, the Prismic api object could have access to the cookies via the request object.

When you launch a preview, the Prismic toolbar sets a cookie with the preview ref. If everything is setup correctly, then the Prismic SDK will check for this cookie and use the Preview ref if the cookie is set (even when the query is make server-side).

So when you're done with your preview session, you need to close out the preview by clicking on the "x" button on the Prismic toolbar or by manually deleting the preview cookie.

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