Permalink
Browse files

feat(HttpClient): add JSON.stringify replacer

Adds optional parameter for replacer to be used when stringifying json.
  • Loading branch information...
jwx committed Oct 14, 2017
1 parent fc1f49a commit 2fc49a98eb3ebd0f132a0a39bff59a4e70ebfd3a
Showing with 3 additions and 2 deletions.
  1. +3 −2 src/util.js
View
@@ -3,8 +3,9 @@
* 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 Blob containing the JSON serialized body.
*/
export function json(body: any): Blob {
return new Blob([JSON.stringify((body !== undefined ? body : {}))], { type: 'application/json' });
export function json(body: any, replacer?: any): Blob {
return new Blob([JSON.stringify((body !== undefined ? body : {}), replacer)], { type: 'application/json' });
}

0 comments on commit 2fc49a9

Please sign in to comment.