Breaking change in v0.20.0
See original GitHub issueDescribe the bug
A breaking change was introduced here: https://github.com/axios/axios/pull/2844/files?file-filters[]=.js&hide-deleted-files=true#diff-597f69416721110963cbbdf72c6d4e6e30d77da5073041b4b10a702c0a7186f0R76
Previously a GET
request would be able to include data
, since before the change above util.merge
would keep the data property passed in config
. Now the mergeConfig
function will ignore the data property in config
, causing the request to be made without data.
Whether or not a GET
request should be able to send a body is debatable I guess, but this change should probably be documented somewhere.
To Reproduce
var utils = require("./utils");
var mergeConfig = require("./core/mergeConfig");
console.log("--- mergeConfig --- ");
console.log(
mergeConfig(
{ data: { hello: "world" } },
{
method: "get",
url: "https://test.com",
}
)
);
console.log("--- utils.merge ---");
console.log(
utils.merge(
{ data: { hello: "world" } },
{
method: "get",
url: "https://test.com",
}
)
);
Result:
--- mergeConfig ---
{ url: 'https://test.com', method: 'get' }
--- utils.merge ---
{ data: { hello: 'world' },
method: 'get',
url: 'https://test.com' }
Expected behavior
A clear and concise description of what you expected to happen.
Environment
- Axios Version [e.g. 0.18.0] 0.20.0
- Adapter [e.g. XHR/HTTP] HTTP
- Browser [e.g. Chrome, Safari] Node
- Browser Version [e.g. 22]
- Node.js Version [e.g. 13.0.1] v10.14.1
- OS: [e.g. iOS 12.1.0, OSX 10.13.4] OSX
- Additional Library Versions [e.g. React 16.7, React Native 0.58.0]
Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:6 (1 by maintainers)
Just as a bump, this issue is impacting me as well. I just noticed it today after upgrading from 0.19.2 to 0.20.0.
I have several systems that interact with APIs that require a request body with certain GET requests, which are now not working after the upgrade since the
data
property in the config object is being ignored.Behavior on 0.19.2
Request being sent: GET https://website.com/api/endpoint Request Body:
Behavior on 0.20.0
Request being sent: GET https://website.com/api/endpoint Request Body: (blank)
I think so too, I’ll close this 👍