remove need for Content Type application/json on post
This commit is contained in:
12
ts/index.ts
12
ts/index.ts
@ -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
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
import 'typings-global'
|
||||
import * as url from 'url'
|
||||
import * as http from 'http'
|
||||
import * as https from 'https'
|
||||
|
Reference in New Issue
Block a user