useExecuteRequest

Generic hook for executing safe context methods with loading state, debounce, and auto-execution.

Returns { loading, data, error, errorMessage, execute, refresh, reset } Handle success/error in your component using the returned data/error values.

Installation

import { useExecuteRequest } from 'uxp/components';

Signature

function useExecuteRequest(config: ExecuteConfig, options?: UseExecuteOptions<T>): UseExecuteResult<T>

Examples

// Auto-execute on mount - state (loading, data, error) updates automatically
const { loading, data, error } = useExecuteRequest({
  type: 'service',
  app: 'UXP',
  service: 'Portal:all'
});
// Auto-execute when dependencies change
const { loading, data, error } = useExecuteRequest({
  type: 'action',
  model: 'User',
  action: 'GetDetails',
  parameters: { id: userId }
}, { dependencies: [userId] });

Last updated