PaginationToken

Functions list resources will return paginated results as an object with two properties:

  • results a single page of results.
  • nextPageToken a token that can be reused to request the next page.
import {Front} from '@frontapp/plugin-sdk';

async function listAllTeammates() {
  const list = await listTeammates();

  let nextPage = list.nextPageToken;
  const teammates = list.results;

  while (nextPage) {
    const {results, nextPageToken} = await listTeammates(nextPage);

    nextPage = nextPageToken;
    teammates.push(...results);
  }

  return teammates;
}