Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieve Multiple Links API returns all links even if version filter is used #385

Open
1 task done
marekrozmus opened this issue Oct 4, 2023 · 0 comments
Open
1 task done
Labels
pending-author [Issue] Awaiting further information or action from the issue author pending-triage [Issue] Ticket is pending to be prioritised

Comments

@marekrozmus
Copy link

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

@marekrozmus marekrozmus added pending-author [Issue] Awaiting further information or action from the issue author pending-triage [Issue] Ticket is pending to be prioritised labels Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-author [Issue] Awaiting further information or action from the issue author pending-triage [Issue] Ticket is pending to be prioritised
Projects
None yet
Development

No branches or pull requests

1 participant