-
-
Notifications
You must be signed in to change notification settings - Fork 11k
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
instance.defaults.headers.common['Authorization'] deffrence from axios.defaults? #341
Comments
Yes, I think there is a bug either in the code or the documentation. The README.md suggests that the following should work: // Set config defaults when creating the instance
var instance = axios.create({
baseURL: 'https://api.example.com'
});
// Alter defaults after instance has been created
instance.defaults.headers.common['Authorization'] = AUTH_TOKEN; But function Axios(defaultConfig) {
this.defaults = utils.merge({}, defaultConfig);
// ...
} So the example above won't work as @mzabriskie Should we fix the code, the docs, or both? |
+1 I'd like to merge defaultConfig to instance by default. |
+1 Yeah, this is bug. But i think it is just wrong docs. For me defaults are defaults. We should leave it alone for axios "default" instance. And headers for instance set as baseURL, as a property of instance object. |
I think a good solution would be to use |
throws
TypeError: Cannot read property 'common' of undefined(…)
while using custom instanec.The text was updated successfully, but these errors were encountered: