Skip to main content
Base interface for all API responses with data and metadata All successful API responses follow this wrapper pattern for consistency and debugging. Errors throw GridError instead of returning error objects.

Remarks

The BaseResponse wrapper provides:
  • data: The actual response payload from the API
  • lastResponse: Request metadata for debugging and tracking
This pattern making it easy to:
  • Access response data via the data property
  • Track requests using lastResponse.requestId for support queries
  • Debug issues with status codes and headers
  • Implement idempotency using lastResponse.idempotencyKey
Note: Errors are NOT returned in the response. Instead, they throw GridError with similar metadata.

Examples

const response = await gridClient.getAccount(accountAddress);

console.log(response.data.address);
console.log(response.data.policies);
const response = await gridClient.createAccount({ email: 'user@example.com' });

console.log('Request ID:', response.lastResponse?.requestId);
console.log('Status:', response.lastResponse?.statusCode);
console.log('Idempotency Key:', response.lastResponse?.idempotencyKey);
try {
  const response = await gridClient.getAccount(accountAddress);
  console.log('Success:', response.data);
} catch (error) {
  if (error instanceof GridError) {
    console.error('Error:', error.message);
    console.error('Request ID:', error.lastResponse?.requestId);
  }
}

Extended by

Type Parameters

Type ParameterDefault typeDescription
TanyType of response data

Properties

PropertyTypeDescription
dataTResponse data from API Contains the actual payload returned by the API endpoint. The type varies based on the specific response interface.
lastResponse?LastResponseResponse metadata with request ID and status code Useful for debugging and tracking requests. Contains: - requestId: Unique identifier for this request - statusCode: HTTP status code (200, 201, etc.) - headers: All response headers - idempotencyKey: Key for idempotent requests (if applicable) See LastResponse