GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Symbol keys are not preserved when data is being passed to transformRequest · Issue #6392 · axios/axios Closed Labels issue::bugThis issue is related to a bug that requires fixing DescriptionDescribe the bugIn 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 Reproducehttps://codesandbox.io/p/sandbox/goofy-boyd-qwmxw5 Code snippetimport axios from "axios"; const client = axios.create({ transformRequest(data) { console.log("transformRequest", data); return data; }, }); const symbolKey = Symbol("example"); console.log(`Axios version: ${axios.VERSION}`); (async () => { const payload = { [symbolKey]: "value", stringKey: "value", }; console.log("payload as submitted", payload); const { data } = await client.post("https://httpbin.org/post", payload); console.log(data); })(); Expected behaviorI expect to see the key [Symbol('example')] in both the "payload as submitted" and "transformRequest" log lines. Axios Version1.6.8 Adapter VersionNo response BrowserNo response Browser VersionNo response Node.js VersionNo response OSNo response Additional Library VersionsNo response Additional context/ScreenshotsNo response ActivityMetadataMetadataAssigneesLabelsissue::bugThis issue is related to a bug that requires fixing TypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |