Files
pole-book/server/node_modules/request-compose/request/json.js

15 lines
339 B
JavaScript

module.exports = (json) => ({options, options: {headers}}) => {
json = typeof json === 'object' ? JSON.stringify(json) : (json || '')
var header = Object.keys(headers)
.find((name) => name.toLowerCase() === 'content-type')
if (!header) {
headers['content-type'] = 'application/json'
}
return {options, body: json}
}