remove need for Content Type application/json on post

This commit is contained in:
2017-12-14 22:33:48 +01:00
parent 00199df3e2
commit 48d839b9b9
11 changed files with 29 additions and 29 deletions

View File

@ -16,6 +16,18 @@ export let get = async (domainArg: string, optionsArg: interfaces.ISmartRequestO
export let post = async (domainArg: string, optionsArg: interfaces.ISmartRequestOptions = {}) => {
optionsArg.method = 'POST'
if (
typeof optionsArg.requestBody === 'object'
&& (!optionsArg.headers || (!optionsArg.headers['Content-Type']))
){
// make sure headers exist
if(!optionsArg.headers) { optionsArg.headers = {} }
// assign the right Content-Type, leaving all other headers in place
Object.assign(optionsArg.headers, {
'Content-Type': 'application/json'
})
}
let response = await request(domainArg, optionsArg)
return response
}

View File

@ -1,4 +1,3 @@
import 'typings-global'
import * as url from 'url'
import * as http from 'http'
import * as https from 'https'