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

Parameters

ParamTypeRequiredDescription
cursorstringYesCursor from previous pageInfo

Returns

ArticlesQueryBuilder (chainable)

Examples

Paginate forward

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

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

Load more pattern

let cursor = null
const allArticles = []

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

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

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

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

    return pageInfo.hasNextPage
}