Closed bmaclean closed 2 years ago
Just to note, I ended up patching this using middleware to serialize outgoing Object
payloads. Still wondering if this could be included in the Wretch spec, though. Thanks!
Hey @bmaclean,
Thanks for reporting this issue!
Just to note, I ended up patching this using middleware to serialize outgoing Object payloads. Still wondering if this could be included in the Wretch spec, though. Thanks!
Glad to know that you found a workaround!
Could the verification for whether the request should be serialized as JSON be expanded beyond checking if the Content-Type begins is a application/json substring?
Yes, I just pushed a commit to relax the check, the content-type is now considered targeting json if it passes the following check:/^application\/.*json.*/
.
I think that it should do the trick!
Related Issues
Related #90
Bug / Improvement Overview
The
body
of requests sent withContent-Type: 'application/vnd.api+json'
aren't being stringified, resulting in an unserialized[object Object]
payload. ThisContent-Type
is used for (de)serialization in many Rails API's.Could this
Content-Type
be considered asjson
for the methodbase
here:https://github.com/elbywan/wretch/blob/master/src/wretcher.ts#L202
We're currently either having to call
.[HTTP method](JSON.stringify(body))
to process our payloads usingContent-Type: 'application/vnd.api+json'
, asjson()
overwrites theContent-Type
. Could the verification for whether the request should be serialized as JSON be expanded beyond checking if theContent-Type
begins is aapplication/json
substring?