export type GetApiMediaDownloadArgs = {body: BodyInit}; export type GetApiMediaDownloadOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download a file * * GET /media/download */ export const getApiMediaDownload = async (args: GetApiMediaDownloadArgs, options?: GetApiMediaDownloadOptions) => { const {baseUrl = "https://www.rcac.purdue.edu/api", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "*/*") const url = `${baseUrl.replace(/\/+$/, '')}/media/download${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 };