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

The adapter's config.url of axios 0.19.1 and above dosn't include baseURL, but axios 0.19.0 and below includes baseURL. #2917

Closed
yujihu opened this issue Apr 22, 2020 · 5 comments

Comments

@yujihu
Copy link

yujihu commented Apr 22, 2020

Describe the bug
The adapter's config.url of axios 0.19.1 and above dosn't include baseURL, but axios 0.19.0 and below includes baseURL.

To Reproduce
I provide an example of running online: https://jsfiddle.net/r70u4wfs/, just change the axios's version, see the log of adapter config.

const newAxios = axios.create({
  baseURL: 'https://httpbin.org/get'
})

newAxios({
	url: '/test',
  adapter: config => {
  	console.log(config)
    return new Promise((resolve, reject) => {
    	resolve({data: {}})
    })
  }
}).then(res => {
	// console.log(res)
}).catch(err => {
	console.log(err)
})

Expected behavior
Different versions should have the same performance. Version 0.19.1 and above should also contain baseURL.

Environment:

  • Axios Version [0.19.1+]
  • OS: [windows 10]
  • Browser [Chrome]
  • Browser Version [80.0.3987.163]

Additional context/Screenshots
Version 0.19.1 and above: dosn't include baseURL
image

Version 0.19.0 and below: includes baseURL
image

@jasonsaayman
Copy link
Member

Hi JihuYu,

I am looking into it, I have validated that this does happen. Interesting to note is that if one is to do it like this:

const axios = require("axios");

const instance = axios({
    baseURL: "https://httpbin.org"
});

instance.get("/get")
    .then((response) => {
        console.log("axios@0.19.1: ", response.data);
    });

You do end up with the call working successfully. I will look into the issue further and let you know.

@chinesedfan
Copy link
Collaborator

See discussions in #2751.

@yujihu
Copy link
Author

yujihu commented Apr 23, 2020

Hi JihuYu,

I am looking into it, I have validated that this does happen. Interesting to note is that if one is to do it like this:

const axios = require("axios");

const instance = axios({
baseURL: "https://httpbin.org"
});

instance.get("/get")
.then((response) => {
console.log("axios@0.19.1: ", response.data);
});
You do end up with the call working successfully. I will look into the issue further and let you know.

I think it should be consistent because many adapters rely on config.url. I hope you find out the reason as soon as possible.

@jasonsaayman
Copy link
Member

Hi @yujihu,

Did you have a look at #2751? I think that might help as there is a lengthy discussion over there about this and similar issues. Please have a look and comment over on that issue if you have additional comments.

Thanks

@jasonsaayman
Copy link
Member

@yujihu I am going to close this for now so that we can rather maintain the discussion over on #2751

@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

3 participants