Bird
0
0

Given this API call: /api/products?page=3&limit=5, which items will the server return if the dataset is ordered and zero-based indexed?

medium📝 Predict Output Q13 of 15
Rest API - Pagination Patterns
Given this API call: /api/products?page=3&limit=5, which items will the server return if the dataset is ordered and zero-based indexed?
AItems 3 to 7
BItems 15 to 19
CItems 10 to 14
DItems 5 to 9
Step-by-Step Solution
Solution:
  1. Step 1: Calculate start index for page 3 with limit 5

    Start index = (page - 1) * limit = (3 - 1) * 5 = 10.
  2. Step 2: Determine item range

    Items returned are from index 10 to 14 (5 items), but zero-based means items 10,11,12,13,14.
  3. Final Answer:

    Items 10 to 14 -> Option C
  4. Quick Check:

    Start = (3-1)*5=10, range 10-14 [OK]
Quick Trick: Start = (page-1)*limit, count = limit [OK]
Common Mistakes:
  • Using page * limit as start index
  • Counting items starting at 1 instead of 0
  • Mixing up start and end indexes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes