axios: url cannot be set in defaults anymore in v0.20.0

Describe the bug

The url option cannot be set in defaults anymore

To Reproduce

Runkit with v0.20.0 (failing): https://runkit.com/embed/ljc1r77qoyte Runkit with v0.19.2 (succeeding): https://runkit.com/embed/ky5awf7v4b4x

const axios = require("axios"),
      request = axios.create({ url: 'https://npm.runkit.com/axios' });

await request().then(({ data }) => data);

Expected behavior

The url option should be settable in defaults.

Environment

  • Axios Version [0.20.0]
  • Adapter [HTTP]
  • Node.js Version [12]
  • OS [Ubuntu 20.04]

Additional context/Screenshots

N/A

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 24 (4 by maintainers)

Most upvoted comments

Perhaps fix typings then? Because it’s really confusing as we provided url to “create” method and debugging this was a nightmare.

I don’t understand why this issue was closed. It’s clearly a breaking change. In 0.18 you can pass a baseURL and a url in the config and it correctly appends the two together. When we went to update to 0.20 it is broken. Using the url config option is clearly documented in the README. This should be reopened and fixed.

There is no test coverage for this as a use case.

https://github.com/axios/axios/blob/405fe690f93264d591b7a64d006314e2222c8727/test/specs/options.spec.js#L59

It is not made clear that the URL option can be set in the create method. Create is intended for creating an instance, not a request.

Defining url in the instance is not a documented way to perform a request. Its seems to me that the that fact that it worked in 0.19.2 was not a feature, but an unexpected success.