Closed easingthemes closed 1 year ago
Example usage
(async () => {
const model = 'article'
const fields = `{
title
_path
authorFragment {
firstName
profilePicture {
...on ImageRef {
_authorUrl
}
}
}
}`
// Cursor based: Loop all pages
const cursorQueryAll = await aemHeadlessClient.runPaginatedQuery(model, { pageSize: 3 }, fields)
for await (let value of cursorQueryAll) {
console.log('cursorQueryAll', value)
}
// Cursor based: Manually get next page
const cursorQuery = await aemHeadlessClient.runPaginatedQuery(model, { pageSize: 4 }, fields)
while (true) {
const { done, value } = await cursorQuery.next();
if (done) break
console.log('cursorQuery', value)
}
})()
I can't really go into the details, as I'm not very familiar with "modern JavaScript", but the general usage patterns look pretty good to me.
Closes https://github.com/adobe/aem-headless-client-js/issues/25