completely refactored utilities for direct rendering, killed iframes
This commit is contained in:
parent
12dd2c6c06
commit
f08a7456ee
37 changed files with 1824 additions and 1350 deletions
12
components/buying-guide/dx.ts
Normal file
12
components/buying-guide/dx.ts
Normal 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue