export type GetApiBrowseVendorOptions = {baseUrl: string, apikey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get the known products for a vendor * * GET /browse/{vendor} */ export const getApiBrowseVendor = async (options: GetApiBrowseVendorOptions) => { const {baseUrl, fetch: fetchFn = fetch, apikey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (apikey !== undefined) headers.set("X-API-KEY", apikey) const url = `${baseUrl.replace(/\/+$/, '')}/browse/${encodeURIComponent(String(args.vendor))}${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 };