My App
RoomKitFrontend

useExamSessions

List exam sessions with filters and pagination

Overview

useExamSessions fetches a paginated list of exam sessions. It calls GET {apiUrl}/exams.

import { useExamSessions } from '@roomkit/react';

Usage

function ExamList({ cohortId }: { cohortId: string }) {
    const { data, isLoading } = useExamSessions({
        filters: {
            cohortId,
            startsAt: new Date('2026-07-01'),
            endsAt: new Date('2026-07-31'),
        },
        pagination: { limit: 20 },
    });

    if (isLoading) return <div>Loading exams...</div>;

    return (
        <ul>
            {data?.items.map((session) => (
                <li key={session.id}>
                    {session.cohortId} — Layout: {session.layoutType} — Capacity: {session.requiredCapacity}
                </li>
            ))}
        </ul>
    );
}

UseExamSessionsOptions

interface UseExamSessionsFilters {
    cohortId?: string;
    startsAt?: Date;
    endsAt?: Date;
    layoutType?: string;
}

interface UseExamSessionsOptions {
    filters?: UseExamSessionsFilters;
    pagination?: Pagination;
    enabled?: boolean;
    onSuccess?: (data: PaginatedResult<ExamSession>) => void;
    onError?: (error: Error) => void;
}
OptionTypeRequiredDescription
filtersUseExamSessionsFiltersNoFilter by cohort, time range, layout type
paginationPaginationNo{ cursor?, limit }
enabledbooleanNoSet to false to skip the request
onSuccess(data) => voidNoCalled when the request succeeds
onError(error) => voidNoCalled when the request fails

Return Value

FieldTypeDescription
dataPaginatedResult<ExamSession> | nullPaginated exam sessions
isLoadingbooleantrue while the request is in flight
errorError | nullThe error if the request failed
refetch() => Promise<void>Manually re-fetch the data

API Endpoint

GET {apiUrl}/exams?cohortId=...&startsAt=...&endsAt=...&layoutType=...

On this page