Skip to content

SDK pagination and errors

for await (const page of client.tasks.pages({ projectId: 'project-id' })) {
for (const task of page.data) {
console.log(task.id)
}
}

The iterator stops when nextCursor is null and detects a repeated cursor instead of looping forever.

import { TeamGridApiError, TeamGridClientError } from '@teamgrid/api-client'
try {
await client.workspace.get()
} catch (error) {
if (error instanceof TeamGridApiError) {
console.error(error.status, error.requestId, error.errors)
} else if (error instanceof TeamGridClientError) {
console.error(error.code, error.message)
} else {
throw error
}
}

TeamGridApiError represents an HTTP response from API v1. TeamGridClientError represents local validation, routing, timeout, response-size, malformed-response, or network failures.

Neither error class stores the bearer credential. Application logs should still avoid serializing request headers, input payloads, or environment variables.