export type GetApiV2ClubsFindArgs = {q: string}; export type GetApiV2ClubsFindOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Find clubs based on query * * GET /v2/clubs/find */ export const getApiV2ClubsFind = async (args: GetApiV2ClubsFindArgs, options?: GetApiV2ClubsFindOptions) => { const {baseUrl = "https://api.xbl.io", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.q != null) query.append("q", String(args.q)) if (apiKey !== undefined) headers.set("X-Authorization", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/v2/clubs/find${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 };