Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to add a sort parameter to the API URL that sorts users by age.
Rest API
GET /api/users?sort=[1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'name' or other fields instead of 'age' when the task asks to sort by age.
✗ Incorrect
The sort parameter should be set to 'age' to sort users by their age.
2fill in blank
mediumComplete the code to add a sort parameter that sorts products by price in descending order.
Rest API
GET /api/products?sort=[1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'price' which sorts ascending by default.
Using 'price_desc' or 'desc_price' which are not standard.
✗ Incorrect
Using '-price' sorts the products by price in descending order in many APIs.
3fill in blank
hardFix the error in the URL to sort orders by date in ascending order.
Rest API
GET /api/orders?sort=[1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-date' which sorts descending.
Using 'asc_date' or 'date_asc' which are not standard.
✗ Incorrect
To sort by date ascending, just use 'date' without any prefix.
4fill in blank
hardFill both blanks to sort employees by last name ascending and then by hire date descending.
Rest API
GET /api/employees?sort=[1],[2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Reversing the order or using wrong prefixes.
✗ Incorrect
The first sort is ascending by last_name, the second is descending by hire_date using '-hire_date'.
5fill in blank
hardFill all three blanks to sort products by category ascending, then by price descending, then by rating ascending.
Rest API
GET /api/products?sort=[1],[2],[3]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong prefixes or wrong order of fields.
✗ Incorrect
Sort first by 'category' ascending, then '-price' descending, then 'rating' ascending.