Skip to main content

Overview

useFetchEvent returns a callable that fetches one event by ID. Visibility is enforced server-side: if the event doesn’t exist or the logged-in user can’t see it, the request returns 404. Pass include to expand associations and populate userRsvp.

Usage Example

import { useFetchEvent } from "@sublay/react-js";

function useLoadEvent(eventId: string) {
  const fetchEvent = useFetchEvent();
  return () => fetchEvent({ eventId, include: ["user", "files", "userRsvp"] });
}

Parameters

eventId
string
required
The event ID.
include
string | string[]
Associations to expand: "user", "space", "files", "userRsvp".

Returns

Returns a Promise<Event> — the Event.

See Also