Skip to content

Commit

Permalink
feat(HttpClient): add JSON.stringify replacer
Browse files Browse the repository at this point in the history
Adds optional parameter for replacer to be used when stringifying json.
  • Loading branch information
jwx committed Oct 14, 2017
1 parent fc1f49a commit 2fc49a9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.