export type GetApiTimelineHomeArgs = {nbpp?: string | undefined, since_id?: string | undefined, last_id?: string | undefined, types?: string | undefined, locale?: string | undefined}; export type GetApiTimelineHomeOptions = {baseUrl?: string | undefined, BetaSeriesApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Display the latest events on the site * * GET /timeline/home */ export const getApiTimelineHome = async (args: GetApiTimelineHomeArgs, options?: GetApiTimelineHomeOptions) => { const {baseUrl = "https://api.betaseries.com", fetch: fetchFn = fetch, BetaSeriesApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.nbpp != null) query.append("nbpp", String(args.nbpp)) if (args.since_id != null) query.append("since_id", String(args.since_id)) if (args.last_id != null) query.append("last_id", String(args.last_id)) if (args.types != null) query.append("types", String(args.types)) if (args.locale != null) query.append("locale", String(args.locale)) if (BetaSeriesApiKey !== undefined) headers.set("X-BetaSeries-Key", BetaSeriesApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/timeline/home${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 };