Vonage Client SDKでのページネーション

Product deprecation notice

Effective April 30th, 2026, Vonage In-App Messaging will no longer be available. Access for new users will be closed, and the service will be discontinued for all existing users.

If you have any questions regarding this product’s discontinuation, please contact your account manager or our support team.

Vonage Client SDKでオブジェクトのリストを取得する場合、レスポンスはページ分割されます。これは、すべてのオブジェクトを一度に返すのではなく、レスポンスのレイテンシとサイズを増加させる、レスポンスのチャンクまたは ページ.例えば getConversations を返します。 ConversationsPage.

ページを返す関数には、ページサイズとカーソルのパラメータがある。カーソルを与えることで、すべての結果を得るまでページをたどることができます。以下は会話を取得する例です。

let conversations, nextCursor, previousCursor
const params = {
    order: "asc", // "desc"
    pageSize: 5,
    cursor: null,
    includeCustomData: true,
    orderBy: null // "CUSTOM_SORT_KEY"     
};

client.getConversations(params)
    .then(conversationsPage => {
        ({conversations, nextCursor, previousCursor} = conversationsPage);
        console.log("Array of Conversations: ", conversations);
        console.log("Cursor for next set of results, if any. Could be null: ", nextCursor);
        console.log("Cursor for previous set of results, if any. Could be null: ", previousCursor);
    }).catch(error => {
        console.error("Error getting Conversations: ", error);
    });

について ConversationsPage がある。 nextCursor そして previousCursor パラメータが必要です。Conversationsの次のページを取得するには、以下を呼び出す。 getConversations の値を提供する。 ConversationsPage.nextCursor カーソルのために:

const params = {
    order: "asc", // "desc"
    pageSize: 5,
    cursor: nextCursor, // previousCursor
    includeCustomData: true,
    orderBy: null // "CUSTOM_SORT_KEY"     
};

client.getConversations(params)
    ...

結果の最後に到達したら nextCursor はnil/nullになる。逆に、結果の先頭に達すると previousCursor はnil/nullとなる。