export type GetApiApiNextjsRoutesStoreRecommendationsArgs = {limit?: string | undefined, preview?: string | undefined, skus: string}; export type GetApiApiNextjsRoutesStoreRecommendationsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Recommended items API for Store/Cart * * GET /api/nextjs-routes/store/recommendations */ export const getApiApiNextjsRoutesStoreRecommendations = async (args: GetApiApiNextjsRoutesStoreRecommendationsArgs, options: GetApiApiNextjsRoutesStoreRecommendationsOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.limit != null) query.append("limit", String(args.limit)) if (args.preview != null) query.append("preview", String(args.preview)) if (args.skus != null) query.append("skus", String(args.skus)) const url = `${baseUrl.replace(/\/+$/, '')}/api/nextjs-routes/store/recommendations${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 (await res.json()) as unknown };