// components/utilities/buying-guide/dx.ts export type Q = Record; export async function dxGet(path: string, query?: Q): Promise { const qs = query ? "?" + new URLSearchParams(Object.entries(query).flatMap(([k, v]) => Array.isArray(v) ? v.map(x => [k, String(x)]) : [[k, String(v)]] )).toString() : ""; const res = await fetch(`/api/dx/${path}${qs}`, { credentials: "include" }); if (!res.ok) throw new Error(`${res.status} ${await res.text()}`); const json = await res.json(); return json?.data ?? json; }