You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're using apisauce, but used yarn's resolutions to update axios to latest version, to pick up security fix. But that broke our app.
We're making a call to post() setting data as undefined (apisauce changes that to null) and we have headers set to Content-Type: "application/json" (data isn't always null/undefined; most times we're sending JSON data). This has worked fine until upgrading axios to 0.21.4 -- now, the payload for is actually null instead of no payload.
This is do to this change from PR #3688: it blindly stringifies data with content type is "application/json".
This was not an issue with 0.21.1.
To Reproduce
Call post() with data set to null. Notice that actual XHR payload is string "null".
it blindly stringifies data with content type is "application/json".
Actually, it does exactly what you ask it to do when you set contentType to application/json - it passes the data as JSON. Null is a valid JSON payload. As discussed earlier, this is expected RFC-compliant behavior. Passing null as a no payload sign is erroneous with application/json, so this is an apisauce issue.
According to json.org, a valid JSON payload is one of these seven values:
Describe the bug
We're using
apisauce
, but used yarn'sresolutions
to updateaxios
to latest version, to pick up security fix. But that broke our app.We're making a call to
post()
setting data asundefined
(apisauce changes that tonull
) and we have headers set toContent-Type: "application/json"
(data isn't alwaysnull
/undefined
; most times we're sending JSON data). This has worked fine until upgradingaxios
to 0.21.4 -- now, the payload for is actuallynull
instead of no payload.This is do to this change from PR #3688: it blindly stringifies data with content type is "application/json".
This was not an issue with 0.21.1.
To Reproduce
Call
post()
with data set tonull
. Notice that actual XHR payload is string "null".Expected behavior
XHR has no payload
Environment
Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.
The text was updated successfully, but these errors were encountered: