#Querying Published Data Without Changing Access Rules

7 messages · Page 1 of 1 (latest)

topaz estuaryBOT
#

I always get confused with the draft/published stuff. I have a global that has drafts enabled and it has some rules to make sure only logged in users to the app can query data. However, now I need to display that on a web page and I would like to NOT change those access rules and still be able to query published data only. So, I was trying to do something like this:

return payload.findGlobal({
      slug,
      overrideAccess: true, // skip the access rules since there's no logged-in user on this web page
      draft: false, // I thought this would remove any drafts
    })

Is there any way I can achieve this?

digital berryBOT
#

Original message from @balmy grail - Moved from #general message

mossy delta
#

Hey @balmy grail that's the correct approach! Are you seeing erros or unexpected data?

balmy grail
#

Hey @mossy delta , so, I think I see what was going on: if I have a global page that has never been publised before, it still returns { _status: draft } in the resonse...without no other data. I'll double check this in a few

mossy delta
#

yes that is correct!

balmy grail
#

Ok. That was it, then...I should have trusted Claude from the beginning that I should check data?.title and not just data...thanks for confirming, Sean.