mirror of
https://github.com/tenrok/axios.git
synced 2026-06-20 20:00:40 +03:00
+1
-2
@@ -1,11 +1,10 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var defaults = require('./defaults');
|
|
||||||
var utils = require('./utils');
|
var utils = require('./utils');
|
||||||
var bind = require('./helpers/bind');
|
var bind = require('./helpers/bind');
|
||||||
var Axios = require('./core/Axios');
|
var Axios = require('./core/Axios');
|
||||||
|
|
||||||
var defaultInstance = new Axios(defaults);
|
var defaultInstance = new Axios();
|
||||||
var axios = module.exports = bind(Axios.prototype.request, defaultInstance);
|
var axios = module.exports = bind(Axios.prototype.request, defaultInstance);
|
||||||
|
|
||||||
// Copy Axios.prototype to axios instance
|
// Copy Axios.prototype to axios instance
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ var combineURLs = require('./../helpers/combineURLs');
|
|||||||
* @param {Object} defaultConfig The default config for the instance
|
* @param {Object} defaultConfig The default config for the instance
|
||||||
*/
|
*/
|
||||||
function Axios(defaultConfig) {
|
function Axios(defaultConfig) {
|
||||||
this.defaults = utils.merge({}, defaultConfig);
|
this.defaults = utils.merge(defaults, defaultConfig);
|
||||||
this.interceptors = {
|
this.interceptors = {
|
||||||
request: new InterceptorManager(),
|
request: new InterceptorManager(),
|
||||||
response: new InterceptorManager()
|
response: new InterceptorManager()
|
||||||
|
|||||||
@@ -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) {
|
it('should have interceptors on the instance', function (done) {
|
||||||
axios.interceptors.request.use(function (config) {
|
axios.interceptors.request.use(function (config) {
|
||||||
config.foo = true;
|
config.foo = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user