hoist-react icon indicating copy to clipboard operation
hoist-react copied to clipboard

Inconsistent behavior in fetch service. XH.fetchJson 'POST' request and XH.fetchService.postJson()

Open oodarluz opened this issue 6 months ago • 0 comments

Using method:'POST' in XH.fetchJson causes the Content-Type header to be hijacked by the withDefaultsAsync function which replaces it with 'application/x-www-form-urlencoded'. Whereas, the XH.fetchService.postJson() sets the Content-Type to 'application/json'.

Overriding the Content-Type to 'application/x-www-form-urlencoded' can cause unexpected behavior. e.g. when using parseRequestJSON() in a controller expecting the request it will throw as the request input stream is being parsed the wrong way

oodarluz avatar Aug 21 '24 22:08 oodarluz