Paging
List endpoints typically require paging. Please adhere to the paging headers when fetching lists.
Headers
Page information is provided via the X-Next-Page
HTTP header.
If a response includes this header then the response body does not contain all of the data in the list or query.
The header provides a full URL to GET
from to obtain the next page. This URL will have all required context to continue the list or query.
Example
This basic example demonstrates using the X-Next-Page
header with fetch.
async function getOrgs(accessToken) {
let orgs = [];
let nextUrl = "https://api.loke.global/organizations";
do {
const response = await fetch(nextUrl, {
headers: {
"Authorization": "Bearer " + accessToken,
}
});
if (!response.ok) {
throw new Error("Network response was not OK");
}
orgs.push(await response.json());
nextUrl = response.headers.get("X-Next-Page");
} while (nextUrl); // nextUrl will be null if there are no more pages
return orgs;
}