Skip to content

Commit

Permalink
Fixing custom instance defaults
Browse files Browse the repository at this point in the history
closes #341
  • Loading branch information
mzabriskie committed Jun 23, 2016
1 parent 10eb238 commit 46eee26
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
3 changes: 1 addition & 2 deletions lib/axios.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
'use strict';

var defaults = require('./defaults');
var utils = require('./utils');
var bind = require('./helpers/bind');
var Axios = require('./core/Axios');

var defaultInstance = new Axios(defaults);
var defaultInstance = new Axios();
var axios = module.exports = bind(Axios.prototype.request, defaultInstance);

// Copy Axios.prototype to axios instance
Expand Down
2 changes: 1 addition & 1 deletion lib/core/Axios.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var combineURLs = require('./../helpers/combineURLs');
* @param {Object} defaultConfig The default config for the instance
*/
function Axios(defaultConfig) {
this.defaults = utils.merge({}, defaultConfig);
this.defaults = utils.merge(defaults, defaultConfig);
this.interceptors = {
request: new InterceptorManager(),
response: new InterceptorManager()
Expand Down
9 changes: 9 additions & 0 deletions test/specs/instance.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ describe('instance', function () {
});
});

it('should have defaults.headers', function () {
var instance = axios.create({
baseURL: 'https://api.example.com'
});

expect(typeof instance.defaults.headers, 'object');
expect(typeof instance.defaults.headers.common, 'object');
});

it('should have interceptors on the instance', function (done) {
axios.interceptors.request.use(function (config) {
config.foo = true;
Expand Down

0 comments on commit 46eee26

Please sign in to comment.