UNPKG

@coinbase/cdp-sdk

Version:

SDK for interacting with the Coinbase Developer Platform Wallet API

21 lines (18 loc) 572 B
import { toJson } from "../json.js"; import { toQueryString } from "../url/qs.js"; export declare namespace GetRequestBody { interface Args { body: unknown; type: "json" | "file" | "bytes" | "form" | "other"; } } export async function getRequestBody({ body, type }: GetRequestBody.Args): Promise<BodyInit | undefined> { if (type === "form") { return toQueryString(body, { arrayFormat: "repeat", encode: true }); } if (type.includes("json")) { return toJson(body); } else { return body as BodyInit; } }