Skip to content

Commit

Permalink
feat: add withJson
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbonnet committed Aug 30, 2020
1 parent c581be2 commit 06f4027
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export { setSessionValue } from './src/setSessionValue'
export { STATUS_CODES } from './src/STATUS_CODES'
export { stop } from './src/stop'
export { toReadableStream } from './src/toReadableStream'
export { withJson } from './src/withJson'
export { writeBody } from './src/writeBody'
export { writeCompressibleBody } from './src/writeCompressibleBody'
export { writeContentEncoding } from './src/writeContentEncoding'
Expand Down
10 changes: 10 additions & 0 deletions src/withJson.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export function withJson(value, options = null) {
return {
...options,
headers: {
...(options != null && options.headers != null ? options.headers : null),
'Content-Type': 'application/json',
},
body: value,
}
}

0 comments on commit 06f4027

Please sign in to comment.