export type GetApiInvitationsAcceptArgs = {token: string}; export type GetApiInvitationsAcceptOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Invitation acceptance HTML form * * GET /invitations/accept */ export const getApiInvitationsAccept = async (args: GetApiInvitationsAcceptArgs, options?: GetApiInvitationsAcceptOptions) => { const {baseUrl = "https://api.your-domain.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/html") if (args.token != null) query.append("token", String(args.token)) const url = `${baseUrl.replace(/\/+$/, '')}/invitations/accept${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.text() };