export type GetApiV1ExercisesArgs = {page?: number | undefined}; export type GetApiV1ExercisesOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * List exercises * * GET /v1/exercises */ export const getApiV1Exercises = async (args: GetApiV1ExercisesArgs, options?: GetApiV1ExercisesOptions) => { const {baseUrl = "http://localhost:3000", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.page != null) query.append("page", String(args.page)) const url = `${baseUrl.replace(/\/+$/, '')}/v1/exercises${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 undefined };