export type GetApiAiNewsArgs = {query?: string | undefined}; export type GetApiAiNewsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Retrieves the latest news whose content contains the query string. * * GET /ai/news */ export const getApiAiNews = async (args: GetApiAiNewsArgs, options?: GetApiAiNewsOptions) => { const {baseUrl = "https://ai.biztoc.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.query != null) query.append("query", String(args.query)) const url = `${baseUrl.replace(/\/+$/, '')}/ai/news${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 };