export type GetApiOrdersCategoriesArgs = {state?: ('all' | 'published' | 'trashed') | undefined, parent?: number | undefined, body: BodyInit}; export type GetApiOrdersCategoriesOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Display a listing of entries * * GET /orders/categories */ export const getApiOrdersCategories = async (args: GetApiOrdersCategoriesArgs, options?: GetApiOrdersCategoriesOptions) => { const {baseUrl = "https://www.rcac.purdue.edu/api", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "*/*") if (args.state != null) query.append("state", String(args.state)) if (args.parent != null) query.append("parent", String(args.parent)) const url = `${baseUrl.replace(/\/+$/, '')}/orders/categories${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers, body: args.body}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };