export type GetApiResearchApiStudiesArgs = {after?: string | undefined, limit?: number | undefined}; export type GetApiResearchApiStudiesOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Open studies, plus those addressed to you when you send your key * * GET /research-api/studies */ export const getApiResearchApiStudies = async (args: GetApiResearchApiStudiesArgs, options?: GetApiResearchApiStudiesOptions) => { const {baseUrl = "https://pickedbyagents.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.after != null) query.append("after", String(args.after)) if (args.limit != null) query.append("limit", String(args.limit)) const url = `${baseUrl.replace(/\/+$/, '')}/research-api/studies${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 };