storyblok-js
storyblok-js copied to clipboard
Retrieve Multiple Links API returns all links even if version filter is used
Describe the issue you're facing
I got a space with many published and draft stories. Some of the were unpublished and published again.
When I query for the links with the API: https://www.storyblok.com/docs/api/content-delivery/v2#core-resources/links/retrieve-multiple-links I get strange results.
I assumed that if I query for published
links then I will get only published
links. After running following code I get following results:
Fetched no param: 448
Filtered draft: 322
Filtered published: 126
Fetched published: 448
Filtered draft: 322
Filtered published: 126
Fetched draft: 810
Filtered draft: 684
Filtered publish: 126
const { data: dataNoParam } = await storyblokApi.get('cdn/links/');
console.log("Fetched no param:", Object.values(dataNoParam.links).length);
console.log("Filtered draft:", Object.values(dataNoParam.links).filter((link) => !link.published).length);
console.log("Filtered published:", Object.values(dataNoParam.links).filter((link) => link.published).length);
const { data: dataPublished } = await storyblokApi.get('cdn/links/', { version: "published" });
console.log("\nFetched published:", Object.values(dataPublished.links).length);
console.log("Filtered draft:", Object.values(dataPublished.links).filter((link) => !link.published).length);
console.log("Filtered published:", Object.values(dataPublished.links).filter((link) => link.published).length);
const { data: dataDraft } = await storyblokApi.get('cdn/links/', { version: "draft" });
console.log("\nFetched draft:", Object.values(dataDraft.links).length);
console.log("Filtered draft:", Object.values(dataDraft.links).filter((link) => !link.published).length);
console.log("Filtered publish:", Object.values(dataDraft.links).filter((link) => link.published).length);
Why the version without filter gets less than the one with draft
filter?
How can I get only published links?
Reproduction
check the description
Steps to reproduce
No response
System Info
Tested on latest: "@storyblok/js": "^2.3.0"
Used Package Manager
npm
Error logs (Optional)
No response
Validations
- [X] Follow our Code of Conduct