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

get is forced upon all reqeusts by default, moved it to default options instead #1059

Closed
wants to merge 3 commits into from

Conversation

vasilevich
Copy link

@vasilevich vasilevich commented Aug 28, 2017

when you perform
axiosinstance.request()
,
this line:
config = utils.merge(defaults, this.defaults, { method: 'get' }, config);
is forcing the "get" method upon ALL requests by default, unless you explicitly call
axiosinstance.request({method:'post'})
even tho in axios.create you set it to post/put/etc.
so I just moved method: 'get' to defaults.
it should be in the defaults anyway, rather than here.

how to reproduce the problem:

const axiosInstance = axios.create({
      baseURL: 'http://localhost',
      responseType: 'json',
       method: 'POST',
      withCredentials: true,
      validateStatus: function (status) {
        return status >= 200 && status < 300; // default
      },
    });
axiosInstance.request(); //the request will be 'GET' not 'POST'
axiosInstance.request({method:'POST'});  /the request will be 'POST' good.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 93.812% when pulling a622a30 on vasilevich:master into 07a7b7c on mzabriskie:master.

added headers to AxiosTransformer
@chinesedfan
Copy link
Collaborator

Fixed by #2383. Thanks all the same.

@chinesedfan chinesedfan closed this Dec 7, 2019
@axios axios locked and limited conversation to collaborators May 3, 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

Successfully merging this pull request may close these issues.

None yet

3 participants