Skip to content

Instance doesn't inherit defaults.baseURL #443

Closed

Activity

  1. franciscolourenco commented on Sep 12, 2016

    @franciscolourenco
    Author

    The same with other options like timeout and interceptors.

  2. cannap commented on Sep 14, 2016

    @cannap

    hi you need to set the base url for the new Axios instance are you sure it should inherit?

    myAxios.defaults.baseURL = "https://api.icndb.com";
  3. franciscolourenco commented on Sep 14, 2016

    @franciscolourenco
    Author

    Thats is what I understood from https://github.com/mzabriskie/axios#config-order-of-precedence
    Global defaults get used if instance options are not provided.
    If Global defaults are changed with axios.defaults then they should be reflected in instances.

    If this is not supported, global defaults is a bit pointless. It would be a nice feature in any case.

  4. nickuraltsev commented on Sep 27, 2016

    @nickuraltsev
    Contributor

    Thank you, @aristidesfl! This is a bug that needs to be fixed asap.

    Details

    In the current version, axios.defaults is the default instance's config which is not the same as the object exported by the defaults module. Custom instances inherit the latter, but not the former, hence changing axios.defaults has no effect on a custom instance's config.

    I think this can be fixed by modifying the axios.create method to merge the default instance config with the specified config as follows:

    axios.create = function create(defaultConfig) {
      return createInstance(utils.merge(axios.defaults, defaultConfig));
    };

    But since there are other issues with configuration (#385, #382, #370), I think it makes sense to address all of them at once . /cc @mzabriskie, @rubennorte

  5. franciscolourenco commented on Sep 27, 2016

    @franciscolourenco
    Author

    @nickuraltsev as a workaround I've been using axios.create(axios.defaults) where axios.defaults is the modified defaults.

  6. yanivefraim commented on Nov 8, 2016

    @yanivefraim

    Is someone working on that? Can I help? (: I would love to continue from here
    @nickuraltsev ?

  7. nickuraltsev commented on Nov 27, 2016

    @nickuraltsev
    Contributor

    Fixed via 6d0e193

  8. added a commit that references this issue on Aug 4, 2017
  9. locked and limited conversation to collaborators on May 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions