Websites v4 docs v5.2.5
    Preparing search index...

    Function useBranches

    • React hook to fetch branches, with support for pagination and filtering.

      The hook handles loading state, error state, and returns the fetched branches. It can also be conditionally enabled.

      Parameters

      • params: UseBranchesProps

        Query parameters for fetching branches (e.g., page, pageSize, placeId, etc.)

      Returns UseBranchesResult

      An object containing:

      • branches: Array of fetched branches
      • loading: Boolean indicating if the request is in progress
      • errors: Any errors encountered during fetch
      const { branches, loading, errors } = useBranches({
      params: { page: 1, pageSize: 10, placeId: '123' },
      enabled: true,
      });

      if (loading) return <div>Loading...</div>;
      if (errors) return <div>Error: {String(errors)}</div>;

      return (
      <ul>
      {branches.map(branch => (
      <li key={branch.id}>{branch.name}</li>
      ))}
      </ul>
      );