Search, filter, sort and pages (E-commerce Store (full stack))
GET /products takes a query string: category=, q= (name contains, any case; + means space), sort=price|-price|name|-name (ties by id), page= (from 1) and limit= (1 to 50, default 10). The answer adds "page", "pages" and "total" (matches before paging). An unknown parameter or bad value → 400 {"error":"bad query: <name"}.
Input: As before.
Output: As before.
Difficulty: Easy. Write your answer in the browser editor, run the examples, then submit it against hidden tests. Python and JavaScript are free; other languages are part of licode Club.
Hint
- Filter, then sort, then cut the page.