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

fix: the error of calling extend to pass parameters #4844 #4857

Merged
merged 2 commits into from Sep 26, 2022

Conversation

techbirds
Copy link
Contributor

@techbirds techbirds commented Jul 17, 2022

Instructions

fix the error of calling extend to pass parameters. Although this will not cause functional defects, it is logically unreasonable.

function createInstance(defaultConfig) {
  const context = new Axios(defaultConfig);
  const instance = bind(Axios.prototype.request, context);

  // Copy axios.prototype to instance
  utils.extend(instance, Axios.prototype, context, {allOwnKeys: true});

  // Copy context to instance
  // utils.extend(instance, context, {allOwnKeys: true}); -> utils.extend(instance, context, null, {allOwnKeys: true});
  utils.extend(instance, context, null, {allOwnKeys: true});

  // Factory for creating new instances
  instance.create = function create(instanceConfig) {
    return createInstance(mergeConfig(defaultConfig, instanceConfig));
  };

  return instance;
}

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

Successfully merging this pull request may close these issues.

None yet

2 participants