export type GetApiFundableLocationSearchArgs = {name: string, type?: string | undefined}; export type GetApiFundableLocationSearchOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Search for location permalinks to filter by * * GET /fundable/location/search */ export const getApiFundableLocationSearch = async (args: GetApiFundableLocationSearchArgs, options?: GetApiFundableLocationSearchOptions) => { const {baseUrl = "https://api.orthogonal.com/mpp", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.name != null) query.append("name", String(args.name)) if (args.type != null) query.append("type", String(args.type)) const url = `${baseUrl.replace(/\/+$/, '')}/fundable/location/search${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 };