Response wrapper for API results providing consistent error handling.
Remarks
Standardizes API responses across the SDK, making it easy to handle
both successful and failed requests. The generic type parameter T
represents the expected data type for successful responses. Check
the success flag before accessing data to ensure type safety.
if (response.success) { console.log('User fetched:', response.data.name); // Access metadata if available if (response.metadata?.cached) { console.log('Data was cached'); } returnresponse.data; } else { console.error('Failed to fetch user:', response.error); returnnull; } }
Response wrapper for API results providing consistent error handling.
Remarks
Standardizes API responses across the SDK, making it easy to handle both successful and failed requests. The generic type parameter T represents the expected data type for successful responses. Check the success flag before accessing data to ensure type safety.
Example