UNPKG

@adonis-agora/authkit-react

Version:

Frontend ergonomics over AuthKit for AdonisJS + Inertia + React apps: a typed useAuth() hook, role-gating hooks and gating components.

11 lines (10 loc) 472 B
import { useAuthkitConfig } from '../config.js'; import { useResource } from './use_resource.js'; export function useOrganization(orgId) { const config = useAuthkitConfig(); const url = orgId ? `${config.endpoints.orgs.replace('/json', '')}/${encodeURIComponent(orgId)}/json` : ''; const { data, loading, error, refetch } = useResource(url, config.csrfToken); return { data, loading: url ? loading : false, error, actions: { refetch } }; }