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

[merge options] Inconsistent behavior between 0.18.1 and 0.19.0 #2374

Closed
liyuanqiu opened this issue Aug 26, 2019 · 5 comments
Closed

[merge options] Inconsistent behavior between 0.18.1 and 0.19.0 #2374

liyuanqiu opened this issue Aug 26, 2019 · 5 comments

Comments

@liyuanqiu
Copy link

liyuanqiu commented Aug 26, 2019

Describe the bug
A clear and concise description of what the bug is. If your problem is not a bug, please file under Support or Usage Question

v0.19.0 changes the source code of merging default options and request options.
But the merging behavior wasn't kept same with v0.18.1.

For example, if default options is:

{
  baseUrl: 'some_url',
  params: {
    foo: 'bar',
  },
}

In v0.18.1, the merged options will contain `params`, but in v0.19.0, the merged options won't contain `params`.

To Reproduce
Code snippet to reproduce, ideally that will work by pasting into something like https://npm.runkit.com/axios, a hosted solution, or a repository that illustrates the issue. If your problem is not reproducible, please file under Support or Usage Question

const instance = axios.create({
  params: {
    foo: 'bar',
  },
});
instance({
  url: 'some_url',
  method: 'get',
});

// in v0.18.1
// GET some_url?foo=bar
// https://codesandbox.io/s/charming-wilson-9wkge

// in v0.19.0
// GET some_url
// https://codesandbox.io/s/nifty-fire-yhhth

Expected behavior
A clear and concise description of what you expected to happen.

I think v0.19.0 shouldn't change the merging behavior.

Environment:

  • Axios Version [0.19.0]
  • OS: [OSX 10.14.6]
  • Browser [Chrome]
  • Browser Version [Version 76.0.3809.100 (Official Build) (64-bit)]
  • Additional Library Versions [React 16.9]

Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.

@G-Rath
Copy link

G-Rath commented Sep 11, 2019

I've just hit this, and found it very surprising. It goes against the use-case of create:

const axios = Axios.create({
  baseURL: url.resolve(process.env.API_URL, '/api'),
  params: { token: process.env.API_TOKEN }
});

While params is less likely to be used compared to say auth or header, at best it's inconsistent - I'm now scared that any property I provide when calling create will actually be used at all, and so have to spend time figuring out what'll happen for every property.

@liyuanqiu liyuanqiu changed the title [merge options] Different behavior between 0.18.1 and 0.19.0 [merge options] Inconsistent behavior between 0.18.1 and 0.19.0 Sep 12, 2019
@reinoute
Copy link

Same here. My project broke when updating to 1.9, so I had to revert.

@willxy
Copy link

willxy commented Oct 12, 2019

possibly related to: #2190

@elboletaire
Copy link

possibly related to: #2190

It is indeed the same issue described in #2190

@chinesedfan
Copy link
Collaborator

So let's track in #2190. Hope someone can merge and release that soon.

@axios axios locked and limited conversation to collaborators May 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants