export type GetApiSitemapIndexXmlOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Sitemap index listing one sitemap per locale * * GET /sitemap-index.xml */ export const getApiSitemapIndexXml = async (options?: GetApiSitemapIndexXmlOptions) => { const {baseUrl = "https://www.1global.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/xml") const url = `${baseUrl.replace(/\/+$/, '')}/sitemap-index.xml${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 res.blob() };