export type GetApiV2AchievementsTitleTitleIdArgs = {titleId: string, continuationToken?: string | undefined}; export type GetApiV2AchievementsTitleTitleIdOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get achievements for a title * * GET /v2/achievements/title/{titleId} */ export const getApiV2AchievementsTitleTitleId = async (args: GetApiV2AchievementsTitleTitleIdArgs, options?: GetApiV2AchievementsTitleTitleIdOptions) => { const {baseUrl = "https://api.xbl.io", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.continuationToken != null) query.append("continuationToken", String(args.continuationToken)) if (apiKey !== undefined) headers.set("X-Authorization", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/v2/achievements/title/${encodeURIComponent(String(args.titleId))}${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 };