export type GetApiApiKeywordsArgs = {includeall?: boolean | undefined}; export type GetApiApiKeywordsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Returns number of holdings which use each keyword. * * GET /api/keywords */ export const getApiApiKeywords = async (args: GetApiApiKeywordsArgs, options: GetApiApiKeywordsOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.includeall != null) query.append("includeall", String(args.includeall)) const url = `${baseUrl.replace(/\/+$/, '')}/api/keywords${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 };