axios 0.9.0 → 0.11.1
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.
- package/CHANGELOG.md +30 -0
- package/README.md +117 -20
- package/UPGRADE_GUIDE.md +1 -1
- package/component.json +1 -1
- package/dist/axios.js +140 -46
- package/dist/axios.map +1 -1
- package/dist/axios.min.js +2 -2
- package/dist/axios.min.map +1 -1
- package/lib/adapters/http.js +72 -34
- package/lib/adapters/xhr.js +59 -14
- package/lib/axios.js +6 -6
- package/lib/defaults.js +10 -7
- package/lib/helpers/btoa.js +6 -6
- package/lib/helpers/settle.js +18 -0
- package/lib/utils.js +23 -1
- package/package.json +25 -17
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,35 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
### 0.11.1 (May 17, 2016)
|
4
|
+
|
5
|
+
- Fixing IE CORS support ([#313](https://github.com/mzabriskie/axios/pull/313))
|
6
|
+
- Fixing detection of `FormData` ([#325](https://github.com/mzabriskie/axios/pull/325))
|
7
|
+
- Adding `Axios` class to exports ([#321](https://github.com/mzabriskie/axios/pull/321))
|
8
|
+
|
9
|
+
### 0.11.0 (Apr 26, 2016)
|
10
|
+
|
11
|
+
- Adding support for Stream with HTTP adapter ([#296](https://github.com/mzabriskie/axios/pull/296))
|
12
|
+
- Adding support for custom HTTP status code error ranges ([#308](https://github.com/mzabriskie/axios/pull/308))
|
13
|
+
- Fixing issue with ArrayBuffer ([#299](https://github.com/mzabriskie/axios/pull/299))
|
14
|
+
|
15
|
+
### 0.10.0 (Apr 20, 2016)
|
16
|
+
|
17
|
+
- Fixing issue with some requests sending `undefined` instead of `null` ([#250](https://github.com/mzabriskie/axios/pull/250))
|
18
|
+
- Fixing basic auth for HTTP adapter ([#252](https://github.com/mzabriskie/axios/pull/252))
|
19
|
+
- Fixing request timeout for XHR adapter ([#227](https://github.com/mzabriskie/axios/pull/227))
|
20
|
+
- Fixing IE8 support by using `onreadystatechange` instead of `onload` ([#249](https://github.com/mzabriskie/axios/pull/249))
|
21
|
+
- Fixing IE9 cross domain requests ([#251](https://github.com/mzabriskie/axios/pull/251))
|
22
|
+
- Adding `maxContentLength` option ([#275](https://github.com/mzabriskie/axios/pull/275))
|
23
|
+
- Fixing XHR support for WebWorker environment ([#279](https://github.com/mzabriskie/axios/pull/279))
|
24
|
+
- Adding request instance to response ([#200](https://github.com/mzabriskie/axios/pull/200))
|
25
|
+
|
26
|
+
### 0.9.1 (Jan 24, 2016)
|
27
|
+
|
28
|
+
- Improving handling of request timeout in node ([#124](https://github.com/mzabriskie/axios/issues/124))
|
29
|
+
- Fixing network errors not rejecting ([#205](https://github.com/mzabriskie/axios/pull/205))
|
30
|
+
- Fixing issue with IE rejecting on HTTP 204 ([#201](https://github.com/mzabriskie/axios/issues/201))
|
31
|
+
- Fixing host/port when following redirects ([#198](https://github.com/mzabriskie/axios/pull/198))
|
32
|
+
|
3
33
|
### 0.9.0 (Jan 18, 2016)
|
4
34
|
|
5
35
|
- Adding support for custom adapters
|
package/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
[](https://travis-ci.org/mzabriskie/axios)
|
5
5
|
[](https://coveralls.io/r/mzabriskie/axios)
|
6
6
|
[](https://www.npmjs.org/package/axios)
|
7
|
-
[](https://gitter.im/mzabriskie/axios)
|
8
8
|
|
9
9
|
Promise based HTTP client for the browser and node.js
|
10
10
|
|
@@ -20,16 +20,18 @@ Promise based HTTP client for the browser and node.js
|
|
20
20
|
|
21
21
|
## Browser Support
|
22
22
|
|
23
|
-
 |  |  |  |  |
|
24
|
-
--- | --- | --- | --- | --- |
|
25
|
-
Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | 8+ ✔ |
|
23
|
+
 |  |  |  |  |  |
|
24
|
+
--- | --- | --- | --- | --- | --- |
|
25
|
+
Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | 8+ ✔ |
|
26
|
+
|
27
|
+
[](https://saucelabs.com/u/axios)
|
26
28
|
|
27
29
|
## Installing
|
28
30
|
|
29
|
-
Using
|
31
|
+
Using cdn:
|
30
32
|
|
31
|
-
```
|
32
|
-
|
33
|
+
```html
|
34
|
+
<script src="https://npmcdn.com/axios/dist/axios.min.js"></script>
|
33
35
|
```
|
34
36
|
|
35
37
|
Using npm:
|
@@ -38,6 +40,12 @@ Using npm:
|
|
38
40
|
$ npm install axios
|
39
41
|
```
|
40
42
|
|
43
|
+
Using bower:
|
44
|
+
|
45
|
+
```bash
|
46
|
+
$ bower install axios
|
47
|
+
```
|
48
|
+
|
41
49
|
## Example
|
42
50
|
|
43
51
|
Performing a `GET` request
|
@@ -105,12 +113,24 @@ Requests can be made by passing the relevant config to `axios`.
|
|
105
113
|
##### axios(config)
|
106
114
|
|
107
115
|
```js
|
116
|
+
// Send a POST request
|
108
117
|
axios({
|
109
|
-
method: '
|
110
|
-
url: '/user/12345'
|
118
|
+
method: 'post',
|
119
|
+
url: '/user/12345',
|
120
|
+
data: {
|
121
|
+
firstName: 'Fred',
|
122
|
+
lastName: 'Flintstone'
|
123
|
+
}
|
111
124
|
});
|
112
125
|
```
|
113
126
|
|
127
|
+
##### axios(url[, config])
|
128
|
+
|
129
|
+
```js
|
130
|
+
// Send a GET request (default method)
|
131
|
+
axios('/user/12345');
|
132
|
+
```
|
133
|
+
|
114
134
|
### Request method aliases
|
115
135
|
|
116
136
|
For convenience aliases have been provided for all supported request methods.
|
@@ -158,7 +178,7 @@ The available instance methods are listed below. The specified config will be me
|
|
158
178
|
##### axios#put(url[, data[, config]])
|
159
179
|
##### axios#patch(url[, data[, config]])
|
160
180
|
|
161
|
-
## Request
|
181
|
+
## Request Config
|
162
182
|
|
163
183
|
These are the available config options for making requests. Only the `url` is required. Requests will default to `GET` if `method` is not specified.
|
164
184
|
|
@@ -166,18 +186,18 @@ These are the available config options for making requests. Only the `url` is re
|
|
166
186
|
{
|
167
187
|
// `url` is the server URL that will be used for the request
|
168
188
|
url: '/user',
|
169
|
-
|
189
|
+
|
170
190
|
// `method` is the request method to be used when making the request
|
171
191
|
method: 'get', // default
|
172
192
|
|
173
|
-
// `baseURL` will be prepended to `url` unless `url` is absolute.
|
174
|
-
// It can be convenient to set `baseURL` for an instance of axios to pass relative URLs
|
193
|
+
// `baseURL` will be prepended to `url` unless `url` is absolute.
|
194
|
+
// It can be convenient to set `baseURL` for an instance of axios to pass relative URLs
|
175
195
|
// to methods of that instance.
|
176
196
|
baseURL: 'https://some-domain.com/api/',
|
177
197
|
|
178
198
|
// `transformRequest` allows changes to the request data before it is sent to the server
|
179
199
|
// This is only applicable for request methods 'PUT', 'POST', and 'PATCH'
|
180
|
-
// The last function in the array must return a string or
|
200
|
+
// The last function in the array must return a string, an ArrayBuffer, or a Stream
|
181
201
|
transformRequest: [function (data) {
|
182
202
|
// Do whatever you want to transform the data
|
183
203
|
|
@@ -195,7 +215,7 @@ These are the available config options for making requests. Only the `url` is re
|
|
195
215
|
// `headers` are custom headers to be sent
|
196
216
|
headers: {'X-Requested-With': 'XMLHttpRequest'},
|
197
217
|
|
198
|
-
// `
|
218
|
+
// `params` are the URL parameters to be sent with the request
|
199
219
|
params: {
|
200
220
|
ID: 12345
|
201
221
|
},
|
@@ -208,7 +228,7 @@ These are the available config options for making requests. Only the `url` is re
|
|
208
228
|
|
209
229
|
// `data` is the data to be sent as the request body
|
210
230
|
// Only applicable for request methods 'PUT', 'POST', and 'PATCH'
|
211
|
-
// When no `transformRequest` is set, must be a string, an ArrayBuffer or a
|
231
|
+
// When no `transformRequest` is set, must be a string, an ArrayBuffer, a hash, or a Stream
|
212
232
|
data: {
|
213
233
|
firstName: 'Fred'
|
214
234
|
},
|
@@ -236,18 +256,35 @@ These are the available config options for making requests. Only the `url` is re
|
|
236
256
|
}
|
237
257
|
|
238
258
|
// `responseType` indicates the type of data that the server will respond with
|
239
|
-
// options are 'arraybuffer', 'blob', 'document', 'json', 'text'
|
259
|
+
// options are 'arraybuffer', 'blob', 'document', 'json', 'text', 'stream'
|
240
260
|
responseType: 'json', // default
|
241
261
|
|
242
262
|
// `xsrfCookieName` is the name of the cookie to use as a value for xsrf token
|
243
263
|
xsrfCookieName: 'XSRF-TOKEN', // default
|
244
264
|
|
245
265
|
// `xsrfHeaderName` is the name of the http header that carries the xsrf token value
|
246
|
-
xsrfHeaderName: 'X-XSRF-TOKEN' // default
|
266
|
+
xsrfHeaderName: 'X-XSRF-TOKEN', // default
|
267
|
+
|
268
|
+
// `progress` allows handling of progress events for 'POST' and 'PUT uploads'
|
269
|
+
// as well as 'GET' downloads
|
270
|
+
progress: function (progressEvent) {
|
271
|
+
// Do whatever you want with the native progress event
|
272
|
+
},
|
273
|
+
|
274
|
+
// `maxContentLength` defines the max size of the http response content allowed
|
275
|
+
maxContentLength: 2000,
|
276
|
+
|
277
|
+
// `validateStatus` defines whether to resolve or reject the promise for a given
|
278
|
+
// HTTP response status code. If `validateStatus` returns `true` (or is set to `null`
|
279
|
+
// or `undefined`), the promise will be resolved; otherwise, the promise will be
|
280
|
+
// rejected.
|
281
|
+
validateStatus: function (status) {
|
282
|
+
return status >= 200 && status < 300; // default
|
283
|
+
}
|
247
284
|
}
|
248
285
|
```
|
249
286
|
|
250
|
-
## Response
|
287
|
+
## Response Schema
|
251
288
|
|
252
289
|
The response for a request contains the following information.
|
253
290
|
|
@@ -283,6 +320,49 @@ axios.get('/user/12345')
|
|
283
320
|
});
|
284
321
|
```
|
285
322
|
|
323
|
+
## Config Defaults
|
324
|
+
|
325
|
+
You can specify config defaults that will be applied to every request.
|
326
|
+
|
327
|
+
### Global axios defaults
|
328
|
+
|
329
|
+
```js
|
330
|
+
axios.defaults.baseURL = 'https://api.example.com';
|
331
|
+
axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;
|
332
|
+
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
|
333
|
+
```
|
334
|
+
|
335
|
+
### Custom instance defaults
|
336
|
+
|
337
|
+
```js
|
338
|
+
// Set config defaults when creating the instance
|
339
|
+
var instance = axios.create({
|
340
|
+
baseURL: 'https://api.example.com'
|
341
|
+
});
|
342
|
+
|
343
|
+
// Alter defaults after instance has been created
|
344
|
+
instance.defaults.headers.common['Authorization'] = AUTH_TOKEN;
|
345
|
+
```
|
346
|
+
|
347
|
+
### Config order of precedence
|
348
|
+
|
349
|
+
Config will be merged with an order of precedence. The order is library defaults found in `lib/defaults.js`, then `defaults` property of the instance, and finally `config` argument for the request. The latter will take precedence over the former. Here's an example.
|
350
|
+
|
351
|
+
```js
|
352
|
+
// Create an instance using the config defaults provided by the library
|
353
|
+
// At this point the timeout config value is `0` as is the default for the library
|
354
|
+
var instance = axios.create();
|
355
|
+
|
356
|
+
// Override timeout default for the library
|
357
|
+
// Now all requests will wait 2.5 seconds before timing out
|
358
|
+
instance.defaults.timeout = 2500;
|
359
|
+
|
360
|
+
// Override timeout for this request as it's known to take a long time
|
361
|
+
instance.get('/longRequest', {
|
362
|
+
timeout: 5000
|
363
|
+
});
|
364
|
+
```
|
365
|
+
|
286
366
|
## Interceptors
|
287
367
|
|
288
368
|
You can intercept requests or responses before they are handled by `then` or `catch`.
|
@@ -340,6 +420,16 @@ axios.get('/user/12345')
|
|
340
420
|
});
|
341
421
|
```
|
342
422
|
|
423
|
+
You can define a custom HTTP status code error range using the `validateStatus` config option.
|
424
|
+
|
425
|
+
```js
|
426
|
+
axios.get('/user/12345', {
|
427
|
+
validateStatus: function (status) {
|
428
|
+
return status < 500; // Reject only if the status code is greater than or equal to 500
|
429
|
+
}
|
430
|
+
})
|
431
|
+
```
|
432
|
+
|
343
433
|
## Semver
|
344
434
|
|
345
435
|
Until axios reaches a `1.0` release, breaking changes will be released with a new minor version. For example `0.5.1`, and `0.5.4` will have the same API, but `0.6.0` will have breaking changes.
|
@@ -353,10 +443,17 @@ If your environment doesn't support ES6 Promises, you can [polyfill](https://git
|
|
353
443
|
axios includes a [TypeScript](http://typescriptlang.org) definition.
|
354
444
|
```typescript
|
355
445
|
/// <reference path="axios.d.ts" />
|
356
|
-
import axios
|
446
|
+
import * as axios from 'axios';
|
357
447
|
axios.get('/user?ID=12345');
|
358
448
|
```
|
359
449
|
|
450
|
+
## Resources
|
451
|
+
|
452
|
+
* [Changelog](https://github.com/mzabriskie/axios/blob/master/CHANGELOG.md)
|
453
|
+
* [Ecosystem](https://github.com/mzabriskie/axios/blob/master/ECOSYSTEM.md)
|
454
|
+
* [Contributing Guide](https://github.com/mzabriskie/axios/blob/master/CONTRIBUTING.md)
|
455
|
+
* [Code of Conduct](https://github.com/mzabriskie/axios/blob/master/CODE_OF_CONDUCT.md)
|
456
|
+
|
360
457
|
## Credits
|
361
458
|
|
362
459
|
axios is heavily inspired by the [$http service](https://docs.angularjs.org/api/ng/service/$http) provided in [Angular](https://angularjs.org/). Ultimately axios is an effort to provide a standalone `$http`-like service for use outside of Angular.
|
package/UPGRADE_GUIDE.md
CHANGED
@@ -6,7 +6,7 @@ The `0.6.0` release contains mostly bug fixes, but there are a couple things to
|
|
6
6
|
|
7
7
|
#### ES6 Promise Polyfill
|
8
8
|
|
9
|
-
Up until the `0.6.0` release ES6 `Promise` was being polyfilled using [es6-promise](https://github.com/jakearchibald/es6-promise). With this release, the polyfill has been removed, and you will need to supply
|
9
|
+
Up until the `0.6.0` release ES6 `Promise` was being polyfilled using [es6-promise](https://github.com/jakearchibald/es6-promise). With this release, the polyfill has been removed, and you will need to supply it yourself if your environment needs it.
|
10
10
|
|
11
11
|
```js
|
12
12
|
require('es6-promise').polyfill();
|
package/component.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"name":"axios","version":"0.9.
|
1
|
+
{"name":"axios","version":"0.9.1","description":"Promise based HTTP client for the browser and node.js","keywords":["xhr","http","ajax","promise","node"],"repo":{"type":"git","url":"https://github.com/mzabriskie/axios.git"},"license":"MIT"}
|
package/dist/axios.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
/* axios v0.
|
1
|
+
/* axios v0.11.1 | (c) 2016 by Matt Zabriskie */
|
2
2
|
(function webpackUniversalModuleDefinition(root, factory) {
|
3
3
|
if(typeof exports === 'object' && typeof module === 'object')
|
4
4
|
module.exports = factory();
|
@@ -66,10 +66,10 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
66
66
|
var defaults = __webpack_require__(2);
|
67
67
|
var utils = __webpack_require__(3);
|
68
68
|
var dispatchRequest = __webpack_require__(4);
|
69
|
-
var InterceptorManager = __webpack_require__(
|
70
|
-
var isAbsoluteURL = __webpack_require__(
|
71
|
-
var combineURLs = __webpack_require__(
|
72
|
-
var bind = __webpack_require__(
|
69
|
+
var InterceptorManager = __webpack_require__(13);
|
70
|
+
var isAbsoluteURL = __webpack_require__(14);
|
71
|
+
var combineURLs = __webpack_require__(15);
|
72
|
+
var bind = __webpack_require__(16);
|
73
73
|
var transformData = __webpack_require__(8);
|
74
74
|
|
75
75
|
function Axios(defaultConfig) {
|
@@ -141,22 +141,22 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
141
141
|
|
142
142
|
var defaultInstance = new Axios(defaults);
|
143
143
|
var axios = module.exports = bind(Axios.prototype.request, defaultInstance);
|
144
|
+
module.exports.Axios = Axios;
|
144
145
|
|
146
|
+
// Expose properties from defaultInstance
|
147
|
+
axios.defaults = defaultInstance.defaults;
|
148
|
+
axios.interceptors = defaultInstance.interceptors;
|
149
|
+
|
150
|
+
// Factory for creating new instances
|
145
151
|
axios.create = function create(defaultConfig) {
|
146
152
|
return new Axios(defaultConfig);
|
147
153
|
};
|
148
154
|
|
149
|
-
// Expose defaults
|
150
|
-
axios.defaults = defaultInstance.defaults;
|
151
|
-
|
152
155
|
// Expose all/spread
|
153
156
|
axios.all = function all(promises) {
|
154
157
|
return Promise.all(promises);
|
155
158
|
};
|
156
|
-
axios.spread = __webpack_require__(
|
157
|
-
|
158
|
-
// Expose interceptors
|
159
|
-
axios.interceptors = defaultInstance.interceptors;
|
159
|
+
axios.spread = __webpack_require__(17);
|
160
160
|
|
161
161
|
// Provide aliases for supported request methods
|
162
162
|
utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
|
@@ -197,11 +197,8 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
197
197
|
};
|
198
198
|
|
199
199
|
module.exports = {
|
200
|
-
transformRequest: [function
|
201
|
-
if (utils.isFormData(data)) {
|
202
|
-
return data;
|
203
|
-
}
|
204
|
-
if (utils.isArrayBuffer(data)) {
|
200
|
+
transformRequest: [function transformRequest(data, headers) {
|
201
|
+
if (utils.isFormData(data) || utils.isArrayBuffer(data) || utils.isStream(data)) {
|
205
202
|
return data;
|
206
203
|
}
|
207
204
|
if (utils.isArrayBufferView(data)) {
|
@@ -225,7 +222,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
225
222
|
return data;
|
226
223
|
}],
|
227
224
|
|
228
|
-
transformResponse: [function
|
225
|
+
transformResponse: [function transformResponse(data) {
|
229
226
|
/*eslint no-param-reassign:0*/
|
230
227
|
if (typeof data === 'string') {
|
231
228
|
data = data.replace(PROTECTION_PREFIX, '');
|
@@ -248,7 +245,13 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
248
245
|
timeout: 0,
|
249
246
|
|
250
247
|
xsrfCookieName: 'XSRF-TOKEN',
|
251
|
-
xsrfHeaderName: 'X-XSRF-TOKEN'
|
248
|
+
xsrfHeaderName: 'X-XSRF-TOKEN',
|
249
|
+
|
250
|
+
maxContentLength: -1,
|
251
|
+
|
252
|
+
validateStatus: function validateStatus(status) {
|
253
|
+
return status >= 200 && status < 300;
|
254
|
+
}
|
252
255
|
};
|
253
256
|
|
254
257
|
|
@@ -291,7 +294,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
291
294
|
* @returns {boolean} True if value is an FormData, otherwise false
|
292
295
|
*/
|
293
296
|
function isFormData(val) {
|
294
|
-
return
|
297
|
+
return (typeof FormData !== 'undefined') && (val instanceof FormData);
|
295
298
|
}
|
296
299
|
|
297
300
|
/**
|
@@ -380,6 +383,26 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
380
383
|
return toString.call(val) === '[object Blob]';
|
381
384
|
}
|
382
385
|
|
386
|
+
/**
|
387
|
+
* Determine if a value is a Function
|
388
|
+
*
|
389
|
+
* @param {Object} val The value to test
|
390
|
+
* @returns {boolean} True if value is a Function, otherwise false
|
391
|
+
*/
|
392
|
+
function isFunction(val) {
|
393
|
+
return toString.call(val) === '[object Function]';
|
394
|
+
}
|
395
|
+
|
396
|
+
/**
|
397
|
+
* Determine if a value is a Stream
|
398
|
+
*
|
399
|
+
* @param {Object} val The value to test
|
400
|
+
* @returns {boolean} True if value is a Stream, otherwise false
|
401
|
+
*/
|
402
|
+
function isStream(val) {
|
403
|
+
return isObject(val) && isFunction(val.pipe);
|
404
|
+
}
|
405
|
+
|
383
406
|
/**
|
384
407
|
* Trim excess whitespace off the beginning and end of a string
|
385
408
|
*
|
@@ -495,6 +518,8 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
495
518
|
isDate: isDate,
|
496
519
|
isFile: isFile,
|
497
520
|
isBlob: isBlob,
|
521
|
+
isFunction: isFunction,
|
522
|
+
isStream: isStream,
|
498
523
|
isStandardBrowserEnv: isStandardBrowserEnv,
|
499
524
|
forEach: forEach,
|
500
525
|
merge: merge,
|
@@ -553,7 +578,8 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
553
578
|
var parseHeaders = __webpack_require__(7);
|
554
579
|
var transformData = __webpack_require__(8);
|
555
580
|
var isURLSameOrigin = __webpack_require__(9);
|
556
|
-
var btoa = window.btoa || __webpack_require__(10);
|
581
|
+
var btoa = (typeof window !== 'undefined' && window.btoa) || __webpack_require__(10);
|
582
|
+
var settle = __webpack_require__(11);
|
557
583
|
|
558
584
|
module.exports = function xhrAdapter(resolve, reject, config) {
|
559
585
|
var requestData = config.data;
|
@@ -564,11 +590,18 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
564
590
|
}
|
565
591
|
|
566
592
|
var request = new XMLHttpRequest();
|
593
|
+
var loadEvent = 'onreadystatechange';
|
594
|
+
var xDomain = false;
|
567
595
|
|
568
596
|
// For IE 8/9 CORS support
|
569
597
|
// Only supports POST and GET calls and doesn't returns the response headers.
|
570
|
-
|
598
|
+
// DON'T do this for testing b/c XMLHttpRequest is mocked, not XDomainRequest.
|
599
|
+
if (("production") !== 'test' && typeof window !== 'undefined' && window.XDomainRequest && !('withCredentials' in request) && !isURLSameOrigin(config.url)) {
|
571
600
|
request = new window.XDomainRequest();
|
601
|
+
loadEvent = 'onload';
|
602
|
+
xDomain = true;
|
603
|
+
request.onprogress = function handleProgress() {};
|
604
|
+
request.ontimeout = function handleTimeout() {};
|
572
605
|
}
|
573
606
|
|
574
607
|
// HTTP basic authentication
|
@@ -584,28 +617,56 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
584
617
|
request.timeout = config.timeout;
|
585
618
|
|
586
619
|
// Listen for ready state
|
587
|
-
request
|
588
|
-
if (!request) {
|
620
|
+
request[loadEvent] = function handleLoad() {
|
621
|
+
if (!request || (request.readyState !== 4 && !xDomain)) {
|
622
|
+
return;
|
623
|
+
}
|
624
|
+
|
625
|
+
// The request errored out and we didn't get a response, this will be
|
626
|
+
// handled by onerror instead
|
627
|
+
if (request.status === 0) {
|
589
628
|
return;
|
590
629
|
}
|
630
|
+
|
591
631
|
// Prepare the response
|
592
632
|
var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
|
593
|
-
var responseData =
|
633
|
+
var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
|
594
634
|
var response = {
|
595
635
|
data: transformData(
|
596
636
|
responseData,
|
597
637
|
responseHeaders,
|
598
638
|
config.transformResponse
|
599
639
|
),
|
600
|
-
|
601
|
-
|
640
|
+
// IE sends 1223 instead of 204 (https://github.com/mzabriskie/axios/issues/201)
|
641
|
+
status: request.status === 1223 ? 204 : request.status,
|
642
|
+
statusText: request.status === 1223 ? 'No Content' : request.statusText,
|
602
643
|
headers: responseHeaders,
|
603
|
-
config: config
|
644
|
+
config: config,
|
645
|
+
request: request
|
604
646
|
};
|
605
|
-
|
606
|
-
(
|
607
|
-
|
608
|
-
|
647
|
+
|
648
|
+
settle(resolve, reject, response);
|
649
|
+
|
650
|
+
// Clean up request
|
651
|
+
request = null;
|
652
|
+
};
|
653
|
+
|
654
|
+
// Handle low level network errors
|
655
|
+
request.onerror = function handleError() {
|
656
|
+
// Real errors are hidden from us by the browser
|
657
|
+
// onerror should only fire if it's a network error
|
658
|
+
reject(new Error('Network Error'));
|
659
|
+
|
660
|
+
// Clean up request
|
661
|
+
request = null;
|
662
|
+
};
|
663
|
+
|
664
|
+
// Handle timeout
|
665
|
+
request.ontimeout = function handleTimeout() {
|
666
|
+
var err = new Error('timeout of ' + config.timeout + 'ms exceeded');
|
667
|
+
err.timeout = config.timeout;
|
668
|
+
err.code = 'ECONNABORTED';
|
669
|
+
reject(err);
|
609
670
|
|
610
671
|
// Clean up request
|
611
672
|
request = null;
|
@@ -615,7 +676,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
615
676
|
// This is only done if running in a standard browser environment.
|
616
677
|
// Specifically not if we're in a web worker, or react-native.
|
617
678
|
if (utils.isStandardBrowserEnv()) {
|
618
|
-
var cookies = __webpack_require__(
|
679
|
+
var cookies = __webpack_require__(12);
|
619
680
|
|
620
681
|
// Add xsrf header
|
621
682
|
var xsrfValue = config.withCredentials || isURLSameOrigin(config.url) ?
|
@@ -656,8 +717,17 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
656
717
|
}
|
657
718
|
}
|
658
719
|
|
659
|
-
if
|
660
|
-
|
720
|
+
// Handle progress if needed
|
721
|
+
if (config.progress) {
|
722
|
+
if (config.method === 'post' || config.method === 'put') {
|
723
|
+
request.upload.addEventListener('progress', config.progress);
|
724
|
+
} else if (config.method === 'get') {
|
725
|
+
request.addEventListener('progress', config.progress);
|
726
|
+
}
|
727
|
+
}
|
728
|
+
|
729
|
+
if (requestData === undefined) {
|
730
|
+
requestData = null;
|
661
731
|
}
|
662
732
|
|
663
733
|
// Send the request
|
@@ -891,12 +961,12 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
891
961
|
|
892
962
|
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
893
963
|
|
894
|
-
function
|
895
|
-
this.message =
|
964
|
+
function E() {
|
965
|
+
this.message = 'String contains an invalid character';
|
896
966
|
}
|
897
|
-
|
898
|
-
|
899
|
-
|
967
|
+
E.prototype = new Error;
|
968
|
+
E.prototype.code = 5;
|
969
|
+
E.prototype.name = 'InvalidCharacterError';
|
900
970
|
|
901
971
|
function btoa(input) {
|
902
972
|
var str = String(input);
|
@@ -913,7 +983,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
913
983
|
) {
|
914
984
|
charCode = str.charCodeAt(idx += 3 / 4);
|
915
985
|
if (charCode > 0xFF) {
|
916
|
-
throw new
|
986
|
+
throw new E();
|
917
987
|
}
|
918
988
|
block = block << 8 | charCode;
|
919
989
|
}
|
@@ -925,6 +995,30 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
925
995
|
|
926
996
|
/***/ },
|
927
997
|
/* 11 */
|
998
|
+
/***/ function(module, exports) {
|
999
|
+
|
1000
|
+
'use strict';
|
1001
|
+
|
1002
|
+
/**
|
1003
|
+
* Resolve or reject a Promise based on response status.
|
1004
|
+
*
|
1005
|
+
* @param {Function} resolve A function that resolves the promise.
|
1006
|
+
* @param {Function} reject A function that rejects the promise.
|
1007
|
+
* @param {object} response The response.
|
1008
|
+
*/
|
1009
|
+
module.exports = function settle(resolve, reject, response) {
|
1010
|
+
var validateStatus = response.config.validateStatus;
|
1011
|
+
// Note: status is not exposed by XDomainRequest
|
1012
|
+
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
1013
|
+
resolve(response);
|
1014
|
+
} else {
|
1015
|
+
reject(response);
|
1016
|
+
}
|
1017
|
+
};
|
1018
|
+
|
1019
|
+
|
1020
|
+
/***/ },
|
1021
|
+
/* 12 */
|
928
1022
|
/***/ function(module, exports, __webpack_require__) {
|
929
1023
|
|
930
1024
|
'use strict';
|
@@ -983,7 +1077,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
983
1077
|
|
984
1078
|
|
985
1079
|
/***/ },
|
986
|
-
/*
|
1080
|
+
/* 13 */
|
987
1081
|
/***/ function(module, exports, __webpack_require__) {
|
988
1082
|
|
989
1083
|
'use strict';
|
@@ -1041,7 +1135,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
1041
1135
|
|
1042
1136
|
|
1043
1137
|
/***/ },
|
1044
|
-
/*
|
1138
|
+
/* 14 */
|
1045
1139
|
/***/ function(module, exports) {
|
1046
1140
|
|
1047
1141
|
'use strict';
|
@@ -1061,7 +1155,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
1061
1155
|
|
1062
1156
|
|
1063
1157
|
/***/ },
|
1064
|
-
/*
|
1158
|
+
/* 15 */
|
1065
1159
|
/***/ function(module, exports) {
|
1066
1160
|
|
1067
1161
|
'use strict';
|
@@ -1079,7 +1173,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
1079
1173
|
|
1080
1174
|
|
1081
1175
|
/***/ },
|
1082
|
-
/*
|
1176
|
+
/* 16 */
|
1083
1177
|
/***/ function(module, exports) {
|
1084
1178
|
|
1085
1179
|
'use strict';
|
@@ -1096,7 +1190,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
1096
1190
|
|
1097
1191
|
|
1098
1192
|
/***/ },
|
1099
|
-
/*
|
1193
|
+
/* 17 */
|
1100
1194
|
/***/ function(module, exports) {
|
1101
1195
|
|
1102
1196
|
'use strict';
|