0
0
Rest APIprogramming~10 mins

Pagination links in Rest API - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to add a 'next' pagination link in the response headers.

Rest API
response.headers['Link'] = '<[1]>; rel="next"'
Drag options to blanks, or click blank then click option'
A/api/items?page=1
B/api/items?page=0
C/api/items?page=2
D/api/items?page=last
Attempts:
3 left
💡 Hint
Common Mistakes
Using the current page URL instead of the next page.
Using an invalid page number like 0.
2fill in blank
medium

Complete the code to add a 'prev' pagination link in the response headers.

Rest API
response.headers['Link'] = '<[1]>; rel="prev"'
Drag options to blanks, or click blank then click option'
A/api/items?page=2
B/api/items?page=1
C/api/items?page=0
D/api/items?page=3
Attempts:
3 left
💡 Hint
Common Mistakes
Using the current page URL instead of the previous page.
Using a page number that is out of range like 0.
3fill in blank
hard

Fix the error in the code to correctly format multiple pagination links in the 'Link' header.

Rest API
response.headers['Link'] = '<[1]>; rel="prev", <[2]>; rel="next"'
Drag options to blanks, or click blank then click option'
A/api/items?page=1
B/api/items?page=2
C/api/items?page=3
D/api/items?page=4
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same URL for both 'prev' and 'next' links.
Not separating the links properly.
4fill in blank
hard

Fill both blanks to correctly generate 'prev' and 'next' pagination links in the 'Link' header.

Rest API
response.headers['Link'] = '<[1]>; rel="prev", <[2]>; rel="next"'
Drag options to blanks, or click blank then click option'
A/api/items?page=1
B/api/items?page=2
C/api/items?page=3
D/api/items?page=4
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping 'prev' and 'next' URLs.
Using the same URL for both links.
5fill in blank
hard

Fill all three blanks to generate a full 'Link' header with 'first', 'prev', and 'next' pagination links.

Rest API
response.headers['Link'] = '<[1]>; rel="first", <[2]>; rel="prev", <[3]>; rel="next"'
Drag options to blanks, or click blank then click option'
A/api/items?page=1
B/api/items?page=2
C/api/items?page=3
D/api/items?page=4
Attempts:
3 left
💡 Hint
Common Mistakes
Incorrect page numbers for 'prev' or 'next'.
Missing the 'first' link.