axios 0.15.2 → 0.15.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of axios might be problematic. Click here for more details.

@@ -6,7 +6,7 @@ var buildURL = require('./../helpers/buildURL');
6
6
  var parseHeaders = require('./../helpers/parseHeaders');
7
7
  var isURLSameOrigin = require('./../helpers/isURLSameOrigin');
8
8
  var createError = require('../core/createError');
9
- var btoa = (typeof window !== 'undefined' && window.btoa) || require('./../helpers/btoa');
9
+ var btoa = (typeof window !== 'undefined' && window.btoa && window.btoa.bind(window)) || require('./../helpers/btoa');
10
10
 
11
11
  module.exports = function xhrAdapter(config) {
12
12
  return new Promise(function dispatchXhrRequest(resolve, reject) {
package/lib/axios.js CHANGED
@@ -3,6 +3,7 @@
3
3
  var utils = require('./utils');
4
4
  var bind = require('./helpers/bind');
5
5
  var Axios = require('./core/Axios');
6
+ var defaults = require('./defaults');
6
7
 
7
8
  /**
8
9
  * Create an instance of Axios
@@ -24,14 +25,14 @@ function createInstance(defaultConfig) {
24
25
  }
25
26
 
26
27
  // Create the default instance to be exported
27
- var axios = createInstance();
28
+ var axios = createInstance(defaults);
28
29
 
29
30
  // Expose Axios class to allow class inheritance
30
31
  axios.Axios = Axios;
31
32
 
32
33
  // Factory for creating new instances
33
- axios.create = function create(defaultConfig) {
34
- return createInstance(defaultConfig);
34
+ axios.create = function create(instanceConfig) {
35
+ return createInstance(utils.merge(defaults, instanceConfig));
35
36
  };
36
37
 
37
38
  // Expose Cancel & CancelToken
package/lib/core/Axios.js CHANGED
@@ -10,10 +10,10 @@ var combineURLs = require('./../helpers/combineURLs');
10
10
  /**
11
11
  * Create a new instance of Axios
12
12
  *
13
- * @param {Object} defaultConfig The default config for the instance
13
+ * @param {Object} instanceConfig The default config for the instance
14
14
  */
15
- function Axios(defaultConfig) {
16
- this.defaults = utils.merge(defaults, defaultConfig);
15
+ function Axios(instanceConfig) {
16
+ this.defaults = instanceConfig;
17
17
  this.interceptors = {
18
18
  request: new InterceptorManager(),
19
19
  response: new InterceptorManager()
package/lib/defaults.js CHANGED
@@ -26,7 +26,7 @@ function getDefaultAdapter() {
26
26
  return adapter;
27
27
  }
28
28
 
29
- module.exports = {
29
+ var defaults = {
30
30
  adapter: getDefaultAdapter(),
31
31
 
32
32
  transformRequest: [function transformRequest(data, headers) {
@@ -64,15 +64,6 @@ module.exports = {
64
64
  return data;
65
65
  }],
66
66
 
67
- headers: {
68
- common: {
69
- 'Accept': 'application/json, text/plain, */*'
70
- },
71
- patch: utils.merge(DEFAULT_CONTENT_TYPE),
72
- post: utils.merge(DEFAULT_CONTENT_TYPE),
73
- put: utils.merge(DEFAULT_CONTENT_TYPE)
74
- },
75
-
76
67
  timeout: 0,
77
68
 
78
69
  xsrfCookieName: 'XSRF-TOKEN',
@@ -84,3 +75,19 @@ module.exports = {
84
75
  return status >= 200 && status < 300;
85
76
  }
86
77
  };
78
+
79
+ defaults.headers = {
80
+ common: {
81
+ 'Accept': 'application/json, text/plain, */*'
82
+ }
83
+ };
84
+
85
+ utils.forEach(['delete', 'get', 'head'], function forEachMehtodNoData(method) {
86
+ defaults.headers[method] = {};
87
+ });
88
+
89
+ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
90
+ defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
91
+ });
92
+
93
+ module.exports = defaults;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "axios",
3
- "version": "0.15.2",
3
+ "version": "0.15.3",
4
4
  "description": "Promise based HTTP client for the browser and node.js",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -32,22 +32,22 @@
32
32
  "homepage": "https://github.com/mzabriskie/axios",
33
33
  "devDependencies": {
34
34
  "coveralls": "^2.11.9",
35
- "es6-promise": "^3.2.1",
36
- "grunt": "0.4.5",
37
- "grunt-banner": "0.6.0",
38
- "grunt-cli": "0.1.13",
39
- "grunt-contrib-clean": "1.0.0",
40
- "grunt-contrib-nodeunit": "1.0.0",
41
- "grunt-contrib-watch": "0.6.1",
42
- "grunt-eslint": "18.0.0",
43
- "grunt-karma": "0.12.1",
44
- "grunt-ts": "5.3.2",
45
- "grunt-typings": "0.1.5",
46
- "grunt-webpack": "1.0.11",
47
- "istanbul-instrumenter-loader": "^0.2.0",
35
+ "es6-promise": "^4.0.5",
36
+ "grunt": "^1.0.1",
37
+ "grunt-banner": "^0.6.0",
38
+ "grunt-cli": "^1.2.0",
39
+ "grunt-contrib-clean": "^1.0.0",
40
+ "grunt-contrib-nodeunit": "^1.0.0",
41
+ "grunt-contrib-watch": "^1.0.0",
42
+ "grunt-eslint": "^19.0.0",
43
+ "grunt-karma": "^2.0.0",
44
+ "grunt-ts": "^6.0.0-beta.3",
45
+ "grunt-typings": "^0.1.5",
46
+ "grunt-webpack": "^1.0.18",
47
+ "istanbul-instrumenter-loader": "^1.0.0",
48
48
  "jasmine-core": "^2.4.1",
49
- "karma": "^0.13.22",
50
- "karma-chrome-launcher": "^1.0.1",
49
+ "karma": "^1.3.0",
50
+ "karma-chrome-launcher": "^2.0.0",
51
51
  "karma-coverage": "^1.0.0",
52
52
  "karma-firefox-launcher": "^1.0.0",
53
53
  "karma-jasmine": "^1.0.2",
@@ -55,23 +55,24 @@
55
55
  "karma-opera-launcher": "^1.0.0",
56
56
  "karma-phantomjs-launcher": "^1.0.0",
57
57
  "karma-safari-launcher": "^1.0.0",
58
- "karma-sauce-launcher": "^1.0.0",
58
+ "karma-sauce-launcher": "^1.1.0",
59
59
  "karma-sinon": "^1.0.5",
60
60
  "karma-sourcemap-loader": "^0.3.7",
61
61
  "karma-webpack": "^1.7.0",
62
- "load-grunt-tasks": "3.4.1",
62
+ "load-grunt-tasks": "^3.5.2",
63
63
  "minimist": "^1.2.0",
64
64
  "phantomjs-prebuilt": "^2.1.7",
65
65
  "sinon": "^1.17.4",
66
66
  "webpack": "^1.13.1",
67
67
  "webpack-dev-server": "^1.14.1",
68
- "url-search-params": "^0.5.0"
68
+ "url-search-params": "^0.6.1",
69
+ "typescript": "^2.0.3"
69
70
  },
70
71
  "browser": {
71
72
  "./lib/adapters/http.js": "./lib/adapters/xhr.js"
72
73
  },
73
- "typings": "./axios.d.ts",
74
+ "typings": "./index.d.ts",
74
75
  "dependencies": {
75
- "follow-redirects": "0.0.7"
76
+ "follow-redirects": "1.0.0"
76
77
  }
77
78
  }