-
-
Notifications
You must be signed in to change notification settings - Fork 11.6k
Default method for an instance always overwritten by get #1121
Copy link
Copy link
Closed
Description
config = utils.merge(defaults, this.defaults, { method: 'get' }, config);The method is always overwritten with the { method: 'get' }, so you are forced to pass the method in each request, like the following:
const myAlwaysPostAPI = axios.create({
baseURL: 'http://localhost'
url : '/myResource',
});
myAlwaysPostAPI({
method: 'post', //always forced to pass this in each API call
data : {key: 'value'}
});this also affects
myAPI.defaults.method = 'post'; //does NOT work
Expected Behavier
const myAlwaysPostAPI = axios.create({
baseURL: 'http://localhost'
url : '/myResource',
method: 'post'
});
myAlwaysPostAPI({
data: {key: 'value'}
});I think the solution is to move the default method to defaults file, will follow this issue with a PR for that.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels