Skip to main content
shoppy.pages.after(cursor)
Fetches pages after the given cursor for forward pagination.

Parameters

ParamTypeRequiredDescription
cursorstringYesCursor from previous pageInfo

Returns

PagesQueryBuilder (chainable)

Examples

Paginate forward

// Get first page
const page1 = await shoppy.pages.limit(10).list()

// Get next page
if (page1.pageInfo.hasNextPage) {
    const page2 = await shoppy.pages
        .limit(10)
        .after(page1.pageInfo.endCursor)
        .list()
}

Load more pattern

let cursor = null
const allPages = []

async function loadMore() {
    const query = shoppy.pages.limit(10)

    if (cursor) {
        query.after(cursor)
    }

    const { items, pageInfo } = await query.list()

    allPages.push(...items)
    cursor = pageInfo.endCursor

    return pageInfo.hasNextPage
}