developit/redaxios

Support axios Config Defaults

leomp12 opened this issue · 2 comments

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

@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'
  }
})

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