completely refactored utilities for direct rendering, killed iframes

This commit is contained in:
makearmy 2025-10-12 22:24:23 -04:00
parent 12dd2c6c06
commit f08a7456ee
37 changed files with 1824 additions and 1350 deletions

View file

@ -0,0 +1,12 @@
// components/utilities/buying-guide/dx.ts
export type Q = Record<string, any>;
export async function dxGet<T>(path: string, query?: Q): Promise<T> {
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;
}