/*** UTILITY ------------------------------------------ ***/ import type { FetcherOptions, FetcherRequest } from "./types.ts"; /*** EXPORT ------------------------------------------- ***/ export function buildHeaders(options: FetcherOptions, req: FetcherRequest): Record { return { "Content-Type": "application/json", ...options.headers, ...req.headers }; } export async function postJson( fetchImpl: typeof globalThis.fetch, url: string, headers: Record, body: unknown ): Promise> { const response = await fetchImpl(url, { body: JSON.stringify(body), headers, method: "POST" }); return await response.json(); }