Courses / Node.js
24. JSON response conventions & pagination headers
Structure JSON responses and use headers/links for pagination metadata.
JavaScript
JSON response conventions & pagination headers
A predictable JSON body plus headers/Link relations convey list data and pagination metadata to clients.
"I want clients to get data and know how many pages exist without embedding everything inside the JSON body."
Return the list payload in a simple JSON structure (items and optional meta) and put pagination details (total, page, per_page, next/prev links) in headers or standardized Link relations so clients can react without parsing nested fields.
"I want clients to get data and know how many pages exist without embedding everything inside the JSON body."
Return the list payload in a simple JSON structure (items and optional meta) and put pagination details (total, page, per_page, next/prev links) in headers or standardized Link relations so clients can react without parsing nested fields.