Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking change in v0.20.0 #3335

Closed
ionTea opened this issue Oct 13, 2020 · 6 comments
Closed

Breaking change in v0.20.0 #3335

ionTea opened this issue Oct 13, 2020 · 6 comments

Comments

@ionTea
Copy link

ionTea commented Oct 13, 2020

Describe the bug

A breaking change was introduced here:
https://github.com/axios/axios/pull/2844/files?file-filters%5B%5D=.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.

@thib3113
Copy link

I think I maybe get the same bug ... I'm using data in GET body, and reverting to 0.19.2 seems to resolve my problem ...

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.
For me, the HTTP 1/1 allow to use GET with body, so an http request library need to implement it .

@nick-w-nick
Copy link

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

const config = {
    data: {
        prop1: 'prop1value',
        prop2: 'prop2value'
    }
}

Axios.get('https://website.com/api/endpoint', config);

Request being sent:
GET https://website.com/api/endpoint
Request Body:

{
    prop1: 'prop1value',
    prop2: 'prop2value'
}

Behavior on 0.20.0

const config = {
    data: {
        prop1: 'prop1value',
        prop2: 'prop2value'
    }
}

Axios.get('https://website.com/api/endpoint', config);

Request being sent:
GET https://website.com/api/endpoint
Request Body: (blank)

@chinesedfan
Copy link
Collaborator

Does it share the same reason with the pinned #3220?

@ionTea
Copy link
Author

ionTea commented Oct 16, 2020

@jasonsaayman
Copy link
Member

Yeah #3220 should fix that up.

@ionTea
Copy link
Author

ionTea commented Oct 16, 2020

I think so too, I'll close this 👍

@ionTea ionTea closed this as completed Oct 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants