Pagination
Provides the ability to separate and traverse through pages of data
Pagination Example
const output: EmailAddress[] = []
let nextToken: string | undefined = undefined
try {
do {
const listOutput = await emailClient.listEmailAddresses({
cachePolicy: CachePolicy.RemoteOnly,
limit = 2,
nextToken, // `undefined` on first invocation
})
output.push(...listOutput.items)
nextToken = listOutput.nextToken
} while (nextToken)
} catch {
// Handle/notify user of errors
}var output: ListOutput<EmailAddress>?
var input = ListEmailAddressesInput(limit: 2, nextToken: nil)
do {
output = try await emailClient.listEmailAddresses(withInput: input)
/*
* This output will contain an `items` array of 2 Email Address objects, as
* well as a non-`nil` `nextToken` which is used in the subsequent call.
*/
input = ListEmailAddressesInput(limit: 2, nextToken: output.nextToken)
output = try await emailClient.listEmailAddresses(withInput: input)
/*
* This output will also contain 2 Email Address objects in the `items` array, however the
* `nextToken` will be `nil`, as there are no more objects for the user to
* fetch.
*/
} catch {
// Handle/notify user of errors
}Last updated