export type GetApiApiApproveRTokenArgs = {token: string, no?: (string | null) | undefined}; export type GetApiApiApproveRTokenOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Approve Review * * GET /api/approve/r/{token} */ export const getApiApiApproveRToken = async (args: GetApiApiApproveRTokenArgs, options: GetApiApiApproveRTokenOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/html") if (args.no != null) query.append("no", String(args.no)) const url = `${baseUrl.replace(/\/+$/, '')}/api/approve/r/${encodeURIComponent(String(args.token))}${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() };