Skip to main content
shoppy.collections.after(cursor)
Sets the cursor for forward pagination. Use to fetch the next page.
This is a chainable method. Call .list() to execute.

Parameters

ParamTypeRequiredDescription
cursorstringYespageInfo.endCursor from previous response

Returns

CollectionsQueryBuilder (chainable)

Examples

Basic pagination

// First page
const page1 = await shoppy.collections.limit(10).list()

// Next page
if (page1.pageInfo.hasNextPage) {
    const page2 = await shoppy.collections
        .limit(10)
        .after(page1.pageInfo.endCursor)
        .list()
}
const page1 = await shoppy.collections.search('sale').limit(10).list()

const page2 = await shoppy.collections
    .search('sale')
    .limit(10)
    .after(page1.pageInfo.endCursor)
    .list()

Load all collections

async function loadAll() {
    const all = []
    let cursor = null
    let hasMore = true

    while (hasMore) {
        const query = shoppy.collections.limit(100)
        if (cursor) query.after(cursor)

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

        all.push(...items)
        hasMore = pageInfo.hasNextPage
        cursor = pageInfo.endCursor
    }

    return all
}