I have a pretty standard list of content elements (collection) that I fetch all at once in order to build a navigation menu. When I then click on one of those nav menu items, the single content is shown on a “detail” page.
However, today I had to learn that, when querying such a collection
, the published
state is not respected. That means even the nav entry of an unpublished content element is created, but when I click on such an unpublished item, the detail page shows an error (404).
Of course I would rather like to have superfluous nav items.
Is there a way to tell strapi.query('introduction').find()
to respect the publication state? I was looking for a way to negate something, like published_at: !null
or maybe even published: true
.
I use:
strapi v3.6,
node 14
UPDATE:
I should add that I tried to add parameters to my query like this:
await ctx.$axios.get('/introductions?_publicationState=live')
which does not seem to work on collections…
And the current way I filter the results is via a separate check against the published_at
parameter (I use Vue):
<li v-if="article.published_at !== null">
which works. But I’d rather not pull too many entries from the server only to then filter them out again…