UNPKG

@arizeai/phoenix-client

Version:

A client for the Phoenix API

23 lines (20 loc) 593 B
import { HeadersOptions } from "openapi-fetch"; /** * A utility function that simplifies the headers for passing to other clients */ export function toObjectHeaders( headers: HeadersOptions ): Record<string, string> { if (Array.isArray(headers)) { return Object.fromEntries(headers); } const objectHeaders: Record<string, string> = {}; for (const [key, value] of Object.entries(headers)) { if (value !== null && value !== undefined) { objectHeaders[key] = Array.isArray(value) ? value.join(", ") : String(value); } } return objectHeaders; }