IResult<T> captures the success-flag-plus-data-plus-error-bag pattern used throughout the SDK. Concrete classes:
Result<T>— generic.AjaxResult<T>— REST-aware (immutable, paginated, decodes Bitrix24 error envelopes).
Shape
interface IResult<T = any> {
readonly isSuccess: boolean
readonly errors: Map<string, Error>
setData(data: T | null | undefined): IResult<T>
getData(): T | null | undefined
addError(error: Error | string, key?: string): IResult
addErrors(errors: (Error | string)[]): IResult
getErrors(): IterableIterator<Error>
getErrorMessages(): string[]
getErrorsByKey(): Record<string, Error>
getErrorMessagesByKey(): Record<string, string>
hasError(key: string): boolean
toString(): string
}
AjaxResult<T> narrows setData to never (immutable response), and overrides getData() to return SuccessPayload<T> when isSuccess.
Typical Usage Pattern
import type { IResult } from '@bitrix24/b24jssdk'
function consume<T>(result: IResult<T>) {
if (!result.isSuccess) {
for (const message of result.getErrorMessages()) {
console.error(message)
}
return
}
const data = result.getData()
// ...
}