Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
backend ruleP2universalStack: data fetching / APIs
data-fetchingpaginationfilteringedge-cases
Over-fetch when later filtering may reduce the result set below the target
If you fetch N items and then filter some out (e.g. dedup against another section), request more than N so the visible count still meets the requirement.
PR: abcn-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codets
| 1 | // need 5 visible, fetch exactly 6, then filter out a duplicate -> only 5 (risky) |
| 2 | const items = await getArticles(ids, 6); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | // fetch extra so post-filter count stays above the target |
| 2 | const items = await getArticles(ids, TARGET + BUFFER); |
Explanation (EN)
Objašnjenje (HR)