UNPKG

@aurelia/fetch-client

Version:

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg)](http://www.typescriptlang.org/) [![CircleCI](https://circleci.com/

11 lines (10 loc) 429 B
/** * Serialize an object to a JSON string. Useful for easily creating JSON fetch request bodies. * * @param body - The object to be serialized to JSON. * @param replacer - The JSON.stringify replacer used when serializing. * @returns A JSON string. */ export function json(body: unknown, replacer?: (key: string, value: unknown) => unknown): string { return JSON.stringify((body !== undefined ? body : {}), replacer); }