Skip to main content

Function: useEndorsements()

useEndorsements(preprintUri, params, options): UseQueryResult<{ cursor: string; endorsements: object[]; hasMore: boolean; summary: { byType: {}; endorserCount: number; total: number; }; total: number; }, Error>

Defined in: web/lib/hooks/use-endorsement.ts:183

Fetches endorsements for a preprint.

Parameters

preprintUri

string

AT-URI of the preprint

params

EndorsementListParams = {}

Query parameters (limit, cursor, contributionType)

options

UseEndorsementsOptions = {}

Hook options

Returns

UseQueryResult<{ cursor: string; endorsements: object[]; hasMore: boolean; summary: { byType: {}; endorserCount: number; total: number; }; total: number; }, Error>

Query result with endorsements data

Remarks

Returns endorsements with aggregated counts by contribution type. Uses a 2-minute stale time as endorsements change less frequently than reviews.

Example

const { data, isLoading, error } = useEndorsements(preprintUri);

if (isLoading) return <EndorsementPanelSkeleton />;

return (
<EndorsementPanel
endorsements={data.endorsements}
summary={data.summary}
/>
);

Throws

When the endorsements API request fails