export type GetApiVulnerabilityLastNumberOptions = {baseUrl: string, apikey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get the last vulnerabilities * * GET /vulnerability/last/{number} */ export const getApiVulnerabilityLastNumber = async (options: GetApiVulnerabilityLastNumberOptions) => { 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(/\/+$/, '')}/vulnerability/last/${encodeURIComponent(String(args.number))}${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 };