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

Support axios Config Defaults #62

Open
leomp12 opened this issue Feb 14, 2021 · 2 comments
Open

Support axios Config Defaults #62

leomp12 opened this issue Feb 14, 2021 · 2 comments

Comments

@leomp12
Copy link

leomp12 commented Feb 14, 2021

https://github.com/axios/axios#config-defaults

As "the goal is to support most/all features", Config Defaults also seems to be an important feature.

Currently, something like:

instance.defaults.headers.get['Content-Type'] = 'application/json'`

Results in:

Uncaught TypeError: instance.defaults.headers is undefined
@developit
Copy link
Owner

@leomp12 I wasn't aware of that usage pattern. FWIW defaults are supported, we just don't prepopulate the headers object. You can do this:

instance.defaults = { headers: { 'Content-Type': 'application/json' } };

or this:

axios = axios.create({
  headers: {
    'Content-Type': 'application/json'
  }
})

@leomp12
Copy link
Author

leomp12 commented Feb 27, 2021

Great @developit , I'll give a try, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants