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
In the app I work on, when I make a request with a payload, I want that request to be transformed almost all of the time. Most of this transformation involves transforming keys in objects from pascalCase to snake_case (and back again when the request resolves). I think this is a stupid decision, but I didn't make it and I can't correct it myself.
In order to handle that transformation, we use the transformRequest option when we construct a customized global client object.
I intended to add a Symbol key to the payload object as a way to signal "don't transform this or its descendants" when it sees that key, but the problem is that by the time the transformer function gets the payload, that key has already been stripped. I think this is a bug.
importaxiosfrom"axios";constclient=axios.create({transformRequest(data){console.log("transformRequest",data);returndata;},});constsymbolKey=Symbol("example");console.log(`Axios version: ${axios.VERSION}`);(async()=>{constpayload={[symbolKey]: "value",stringKey: "value",};console.log("payload as submitted",payload);const{ data }=awaitclient.post("https://httpbin.org/post",payload);console.log(data);})();
Expected behavior
I expect to see the key [Symbol('example')] in both the "payload as submitted" and "transformRequest" log lines.
Axios Version
1.6.8
Adapter Version
No response
Browser
No response
Browser Version
No response
Node.js Version
No response
OS
No response
Additional Library Versions
No response
Additional context/Screenshots
No response
The text was updated successfully, but these errors were encountered:
Describe the bug
In the app I work on, when I make a request with a payload, I want that request to be transformed almost all of the time. Most of this transformation involves transforming keys in objects from pascalCase to snake_case (and back again when the request resolves). I think this is a stupid decision, but I didn't make it and I can't correct it myself.
In order to handle that transformation, we use the transformRequest option when we construct a customized global client object.
I intended to add a Symbol key to the payload object as a way to signal "don't transform this or its descendants" when it sees that key, but the problem is that by the time the transformer function gets the payload, that key has already been stripped. I think this is a bug.
To Reproduce
https://codesandbox.io/p/sandbox/goofy-boyd-qwmxw5
Code snippet
Expected behavior
I expect to see the key [Symbol('example')] in both the "payload as submitted" and "transformRequest" log lines.
Axios Version
1.6.8
Adapter Version
No response
Browser
No response
Browser Version
No response
Node.js Version
No response
OS
No response
Additional Library Versions
No response
Additional context/Screenshots
No response
The text was updated successfully, but these errors were encountered: