Core Concepts
Response Model
Understand the unified response contract used across all SDK calls.
All methods return the same envelope:
type SazitoResponse<T> = {
data: T;
error?: never;
} | {
data?: never;
error: {
status?: number;
message: string;
type: 'network' | 'api' | 'validation';
details?: any;
};
};The two branches are mutually exclusive: successful calls return data, while
failures return error. API failures are not thrown.
Handling strategy
const res = await client.categories.get(110);
if (res.error) {
if (res.error.type === 'validation') {
// usually missing local checkout state
}
if (res.error.type === 'network') {
// timeout, offline, DNS, etc.
}
if (res.error.type === 'api') {
// request was rejected
}
return;
}
console.log(res.data);Error type semantics
validation: local precondition failed before request execution.network: transport/runtime failure.detailscontains the errorname,message, andcodewhen available, plus its underlyingcause(for example a TLS or DNS failure).api: request reached server and failed with non-2xx status.
This contract is designed for predictable UI state handling in large applications.