axios 0.26.0 → 0.27.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.
@@ -1,8 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var utils = require('./utils');
4
- var normalizeHeaderName = require('./helpers/normalizeHeaderName');
5
- var enhanceError = require('./core/enhanceError');
3
+ var utils = require('../utils');
4
+ var normalizeHeaderName = require('../helpers/normalizeHeaderName');
5
+ var AxiosError = require('../core/AxiosError');
6
+ var transitionalDefaults = require('./transitional');
7
+ var toFormData = require('../helpers/toFormData');
6
8
 
7
9
  var DEFAULT_CONTENT_TYPE = {
8
10
  'Content-Type': 'application/x-www-form-urlencoded'
@@ -18,10 +20,10 @@ function getDefaultAdapter() {
18
20
  var adapter;
19
21
  if (typeof XMLHttpRequest !== 'undefined') {
20
22
  // For browsers use XHR adapter
21
- adapter = require('./adapters/xhr');
23
+ adapter = require('../adapters/xhr');
22
24
  } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
23
25
  // For node use HTTP adapter
24
- adapter = require('./adapters/http');
26
+ adapter = require('../adapters/http');
25
27
  }
26
28
  return adapter;
27
29
  }
@@ -43,11 +45,7 @@ function stringifySafely(rawValue, parser, encoder) {
43
45
 
44
46
  var defaults = {
45
47
 
46
- transitional: {
47
- silentJSONParsing: true,
48
- forcedJSONParsing: true,
49
- clarifyTimeoutError: false
50
- },
48
+ transitional: transitionalDefaults,
51
49
 
52
50
  adapter: getDefaultAdapter(),
53
51
 
@@ -71,10 +69,20 @@ var defaults = {
71
69
  setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
72
70
  return data.toString();
73
71
  }
74
- if (utils.isObject(data) || (headers && headers['Content-Type'] === 'application/json')) {
72
+
73
+ var isObjectPayload = utils.isObject(data);
74
+ var contentType = headers && headers['Content-Type'];
75
+
76
+ var isFileList;
77
+
78
+ if ((isFileList = utils.isFileList(data)) || (isObjectPayload && contentType === 'multipart/form-data')) {
79
+ var _FormData = this.env && this.env.FormData;
80
+ return toFormData(isFileList ? {'files[]': data} : data, _FormData && new _FormData());
81
+ } else if (isObjectPayload || contentType === 'application/json') {
75
82
  setContentTypeIfUnset(headers, 'application/json');
76
83
  return stringifySafely(data);
77
84
  }
85
+
78
86
  return data;
79
87
  }],
80
88
 
@@ -90,7 +98,7 @@ var defaults = {
90
98
  } catch (e) {
91
99
  if (strictJSONParsing) {
92
100
  if (e.name === 'SyntaxError') {
93
- throw enhanceError(e, this, 'E_JSON_PARSE');
101
+ throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
94
102
  }
95
103
  throw e;
96
104
  }
@@ -112,6 +120,10 @@ var defaults = {
112
120
  maxContentLength: -1,
113
121
  maxBodyLength: -1,
114
122
 
123
+ env: {
124
+ FormData: require('./env/FormData')
125
+ },
126
+
115
127
  validateStatus: function validateStatus(status) {
116
128
  return status >= 200 && status < 300;
117
129
  },
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ silentJSONParsing: true,
5
+ forcedJSONParsing: true,
6
+ clarifyTimeoutError: false
7
+ };
package/lib/env/data.js CHANGED
@@ -1,3 +1,3 @@
1
1
  module.exports = {
2
- "version": "0.26.0"
2
+ "version": "0.27.1"
3
3
  };
@@ -0,0 +1,2 @@
1
+ // eslint-disable-next-line strict
2
+ module.exports = null;
@@ -1,55 +1,72 @@
1
1
  'use strict';
2
2
 
3
- function combinedKey(parentKey, elKey) {
4
- return parentKey + '.' + elKey;
5
- }
3
+ var utils = require('../utils');
4
+
5
+ /**
6
+ * Convert a data object to FormData
7
+ * @param {Object} obj
8
+ * @param {?Object} [formData]
9
+ * @returns {Object}
10
+ **/
11
+
12
+ function toFormData(obj, formData) {
13
+ // eslint-disable-next-line no-param-reassign
14
+ formData = formData || new FormData();
15
+
16
+ var stack = [];
6
17
 
7
- function buildFormData(formData, data, parentKey) {
8
- if (Array.isArray(data)) {
9
- data.forEach(function buildArray(el, i) {
10
- buildFormData(formData, el, combinedKey(parentKey, i));
11
- });
12
- } else if (
13
- typeof data === 'object' &&
14
- !(data instanceof File || data === null)
15
- ) {
16
- Object.keys(data).forEach(function buildObject(key) {
17
- buildFormData(
18
- formData,
19
- data[key],
20
- parentKey ? combinedKey(parentKey, key) : key
21
- );
22
- });
23
- } else {
24
- if (data === undefined) {
25
- return;
18
+ function convertValue(value) {
19
+ if (value === null) return '';
20
+
21
+ if (utils.isDate(value)) {
22
+ return value.toISOString();
23
+ }
24
+
25
+ if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) {
26
+ return typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
26
27
  }
27
28
 
28
- var value =
29
- typeof data === 'boolean' || typeof data === 'number'
30
- ? data.toString()
31
- : data;
32
- formData.append(parentKey, value);
29
+ return value;
33
30
  }
34
- }
35
31
 
36
- /**
37
- * convert a data object to FormData
38
- *
39
- * type FormDataPrimitive = string | Blob | number | boolean
40
- * interface FormDataNest {
41
- * [x: string]: FormVal
42
- * }
43
- *
44
- * type FormVal = FormDataNest | FormDataPrimitive
45
- *
46
- * @param {FormVal} data
47
- */
48
-
49
- module.exports = function getFormData(data) {
50
- var formData = new FormData();
51
-
52
- buildFormData(formData, data);
32
+ function build(data, parentKey) {
33
+ if (utils.isPlainObject(data) || utils.isArray(data)) {
34
+ if (stack.indexOf(data) !== -1) {
35
+ throw Error('Circular reference detected in ' + parentKey);
36
+ }
37
+
38
+ stack.push(data);
39
+
40
+ utils.forEach(data, function each(value, key) {
41
+ if (utils.isUndefined(value)) return;
42
+ var fullKey = parentKey ? parentKey + '.' + key : key;
43
+ var arr;
44
+
45
+ if (value && !parentKey && typeof value === 'object') {
46
+ if (utils.endsWith(key, '{}')) {
47
+ // eslint-disable-next-line no-param-reassign
48
+ value = JSON.stringify(value);
49
+ } else if (utils.endsWith(key, '[]') && (arr = utils.toArray(value))) {
50
+ // eslint-disable-next-line func-names
51
+ arr.forEach(function(el) {
52
+ !utils.isUndefined(el) && formData.append(fullKey, convertValue(el));
53
+ });
54
+ return;
55
+ }
56
+ }
57
+
58
+ build(value, fullKey);
59
+ });
60
+
61
+ stack.pop();
62
+ } else {
63
+ formData.append(parentKey, convertValue(data));
64
+ }
65
+ }
66
+
67
+ build(obj);
53
68
 
54
69
  return formData;
55
- };
70
+ }
71
+
72
+ module.exports = toFormData;
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var VERSION = require('../env/data').version;
4
+ var AxiosError = require('../core/AxiosError');
4
5
 
5
6
  var validators = {};
6
7
 
@@ -28,7 +29,10 @@ validators.transitional = function transitional(validator, version, message) {
28
29
  // eslint-disable-next-line func-names
29
30
  return function(value, opt, opts) {
30
31
  if (validator === false) {
31
- throw new Error(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')));
32
+ throw new AxiosError(
33
+ formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
34
+ AxiosError.ERR_DEPRECATED
35
+ );
32
36
  }
33
37
 
34
38
  if (version && !deprecatedWarnings[opt]) {
@@ -55,7 +59,7 @@ validators.transitional = function transitional(validator, version, message) {
55
59
 
56
60
  function assertOptions(options, schema, allowUnknown) {
57
61
  if (typeof options !== 'object') {
58
- throw new TypeError('options must be an object');
62
+ throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
59
63
  }
60
64
  var keys = Object.keys(options);
61
65
  var i = keys.length;
@@ -66,12 +70,12 @@ function assertOptions(options, schema, allowUnknown) {
66
70
  var value = options[opt];
67
71
  var result = value === undefined || validator(value, opt, options);
68
72
  if (result !== true) {
69
- throw new TypeError('option ' + opt + ' must be ' + result);
73
+ throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
70
74
  }
71
75
  continue;
72
76
  }
73
77
  if (allowUnknown !== true) {
74
- throw Error('Unknown option ' + opt);
78
+ throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
75
79
  }
76
80
  }
77
81
  }
package/lib/utils.js CHANGED
@@ -6,6 +6,22 @@ var bind = require('./helpers/bind');
6
6
 
7
7
  var toString = Object.prototype.toString;
8
8
 
9
+ // eslint-disable-next-line func-names
10
+ var kindOf = (function(cache) {
11
+ // eslint-disable-next-line func-names
12
+ return function(thing) {
13
+ var str = toString.call(thing);
14
+ return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
15
+ };
16
+ })(Object.create(null));
17
+
18
+ function kindOfTest(type) {
19
+ type = type.toLowerCase();
20
+ return function isKindOf(thing) {
21
+ return kindOf(thing) === type;
22
+ };
23
+ }
24
+
9
25
  /**
10
26
  * Determine if a value is an Array
11
27
  *
@@ -40,22 +56,12 @@ function isBuffer(val) {
40
56
  /**
41
57
  * Determine if a value is an ArrayBuffer
42
58
  *
59
+ * @function
43
60
  * @param {Object} val The value to test
44
61
  * @returns {boolean} True if value is an ArrayBuffer, otherwise false
45
62
  */
46
- function isArrayBuffer(val) {
47
- return toString.call(val) === '[object ArrayBuffer]';
48
- }
63
+ var isArrayBuffer = kindOfTest('ArrayBuffer');
49
64
 
50
- /**
51
- * Determine if a value is a FormData
52
- *
53
- * @param {Object} val The value to test
54
- * @returns {boolean} True if value is an FormData, otherwise false
55
- */
56
- function isFormData(val) {
57
- return toString.call(val) === '[object FormData]';
58
- }
59
65
 
60
66
  /**
61
67
  * Determine if a value is a view on an ArrayBuffer
@@ -110,7 +116,7 @@ function isObject(val) {
110
116
  * @return {boolean} True if value is a plain Object, otherwise false
111
117
  */
112
118
  function isPlainObject(val) {
113
- if (toString.call(val) !== '[object Object]') {
119
+ if (kindOf(val) !== 'object') {
114
120
  return false;
115
121
  }
116
122
 
@@ -121,32 +127,38 @@ function isPlainObject(val) {
121
127
  /**
122
128
  * Determine if a value is a Date
123
129
  *
130
+ * @function
124
131
  * @param {Object} val The value to test
125
132
  * @returns {boolean} True if value is a Date, otherwise false
126
133
  */
127
- function isDate(val) {
128
- return toString.call(val) === '[object Date]';
129
- }
134
+ var isDate = kindOfTest('Date');
130
135
 
131
136
  /**
132
137
  * Determine if a value is a File
133
138
  *
139
+ * @function
134
140
  * @param {Object} val The value to test
135
141
  * @returns {boolean} True if value is a File, otherwise false
136
142
  */
137
- function isFile(val) {
138
- return toString.call(val) === '[object File]';
139
- }
143
+ var isFile = kindOfTest('File');
140
144
 
141
145
  /**
142
146
  * Determine if a value is a Blob
143
147
  *
148
+ * @function
144
149
  * @param {Object} val The value to test
145
150
  * @returns {boolean} True if value is a Blob, otherwise false
146
151
  */
147
- function isBlob(val) {
148
- return toString.call(val) === '[object Blob]';
149
- }
152
+ var isBlob = kindOfTest('Blob');
153
+
154
+ /**
155
+ * Determine if a value is a FileList
156
+ *
157
+ * @function
158
+ * @param {Object} val The value to test
159
+ * @returns {boolean} True if value is a File, otherwise false
160
+ */
161
+ var isFileList = kindOfTest('FileList');
150
162
 
151
163
  /**
152
164
  * Determine if a value is a Function
@@ -169,14 +181,27 @@ function isStream(val) {
169
181
  }
170
182
 
171
183
  /**
172
- * Determine if a value is a URLSearchParams object
184
+ * Determine if a value is a FormData
173
185
  *
186
+ * @param {Object} thing The value to test
187
+ * @returns {boolean} True if value is an FormData, otherwise false
188
+ */
189
+ function isFormData(thing) {
190
+ var pattern = '[object FormData]';
191
+ return thing && (
192
+ (typeof FormData === 'function' && thing instanceof FormData) ||
193
+ toString.call(thing) === pattern ||
194
+ (isFunction(thing.toString) && thing.toString() === pattern)
195
+ );
196
+ }
197
+
198
+ /**
199
+ * Determine if a value is a URLSearchParams object
200
+ * @function
174
201
  * @param {Object} val The value to test
175
202
  * @returns {boolean} True if value is a URLSearchParams object, otherwise false
176
203
  */
177
- function isURLSearchParams(val) {
178
- return toString.call(val) === '[object URLSearchParams]';
179
- }
204
+ var isURLSearchParams = kindOfTest('URLSearchParams');
180
205
 
181
206
  /**
182
207
  * Trim excess whitespace off the beginning and end of a string
@@ -323,6 +348,94 @@ function stripBOM(content) {
323
348
  return content;
324
349
  }
325
350
 
351
+ /**
352
+ * Inherit the prototype methods from one constructor into another
353
+ * @param {function} constructor
354
+ * @param {function} superConstructor
355
+ * @param {object} [props]
356
+ * @param {object} [descriptors]
357
+ */
358
+
359
+ function inherits(constructor, superConstructor, props, descriptors) {
360
+ constructor.prototype = Object.create(superConstructor.prototype, descriptors);
361
+ constructor.prototype.constructor = constructor;
362
+ props && Object.assign(constructor.prototype, props);
363
+ }
364
+
365
+ /**
366
+ * Resolve object with deep prototype chain to a flat object
367
+ * @param {Object} sourceObj source object
368
+ * @param {Object} [destObj]
369
+ * @param {Function} [filter]
370
+ * @returns {Object}
371
+ */
372
+
373
+ function toFlatObject(sourceObj, destObj, filter) {
374
+ var props;
375
+ var i;
376
+ var prop;
377
+ var merged = {};
378
+
379
+ destObj = destObj || {};
380
+
381
+ do {
382
+ props = Object.getOwnPropertyNames(sourceObj);
383
+ i = props.length;
384
+ while (i-- > 0) {
385
+ prop = props[i];
386
+ if (!merged[prop]) {
387
+ destObj[prop] = sourceObj[prop];
388
+ merged[prop] = true;
389
+ }
390
+ }
391
+ sourceObj = Object.getPrototypeOf(sourceObj);
392
+ } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
393
+
394
+ return destObj;
395
+ }
396
+
397
+ /*
398
+ * determines whether a string ends with the characters of a specified string
399
+ * @param {String} str
400
+ * @param {String} searchString
401
+ * @param {Number} [position= 0]
402
+ * @returns {boolean}
403
+ */
404
+ function endsWith(str, searchString, position) {
405
+ str = String(str);
406
+ if (position === undefined || position > str.length) {
407
+ position = str.length;
408
+ }
409
+ position -= searchString.length;
410
+ var lastIndex = str.indexOf(searchString, position);
411
+ return lastIndex !== -1 && lastIndex === position;
412
+ }
413
+
414
+
415
+ /**
416
+ * Returns new array from array like object
417
+ * @param {*} [thing]
418
+ * @returns {Array}
419
+ */
420
+ function toArray(thing) {
421
+ if (!thing) return null;
422
+ var i = thing.length;
423
+ if (isUndefined(i)) return null;
424
+ var arr = new Array(i);
425
+ while (i-- > 0) {
426
+ arr[i] = thing[i];
427
+ }
428
+ return arr;
429
+ }
430
+
431
+ // eslint-disable-next-line func-names
432
+ var isTypedArray = (function(TypedArray) {
433
+ // eslint-disable-next-line func-names
434
+ return function(thing) {
435
+ return TypedArray && thing instanceof TypedArray;
436
+ };
437
+ })(typeof Uint8Array !== 'undefined' && Object.getPrototypeOf(Uint8Array));
438
+
326
439
  module.exports = {
327
440
  isArray: isArray,
328
441
  isArrayBuffer: isArrayBuffer,
@@ -345,5 +458,13 @@ module.exports = {
345
458
  merge: merge,
346
459
  extend: extend,
347
460
  trim: trim,
348
- stripBOM: stripBOM
461
+ stripBOM: stripBOM,
462
+ inherits: inherits,
463
+ toFlatObject: toFlatObject,
464
+ kindOf: kindOf,
465
+ kindOfTest: kindOfTest,
466
+ endsWith: endsWith,
467
+ toArray: toArray,
468
+ isTypedArray: isTypedArray,
469
+ isFileList: isFileList
349
470
  };
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "axios",
3
- "version": "0.26.0",
3
+ "version": "0.27.1",
4
4
  "description": "Promise based HTTP client for the browser and node.js",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "scripts": {
8
8
  "test": "grunt test && dtslint",
9
9
  "start": "node ./sandbox/server.js",
10
- "build": "NODE_ENV=production grunt build",
10
+ "build": "cross-env NODE_ENV=production grunt build",
11
11
  "preversion": "grunt version && npm test",
12
12
  "version": "npm run build && git add -A dist && git add CHANGELOG.md bower.json package.json",
13
13
  "postversion": "git push && git push --tags",
@@ -33,24 +33,26 @@
33
33
  },
34
34
  "homepage": "https://axios-http.com",
35
35
  "devDependencies": {
36
- "abortcontroller-polyfill": "^1.5.0",
37
- "coveralls": "^3.0.0",
38
- "dtslint": "^4.1.6",
39
- "es6-promise": "^4.2.4",
40
- "grunt": "^1.3.0",
36
+ "abortcontroller-polyfill": "^1.7.3",
37
+ "coveralls": "^3.1.1",
38
+ "cross-env": "^7.0.3",
39
+ "dtslint": "^4.2.1",
40
+ "es6-promise": "^4.2.8",
41
+ "formidable": "^2.0.1",
42
+ "grunt": "^1.4.1",
41
43
  "grunt-banner": "^0.6.0",
42
- "grunt-cli": "^1.2.0",
43
- "grunt-contrib-clean": "^1.1.0",
44
- "grunt-contrib-watch": "^1.0.0",
45
- "grunt-eslint": "^23.0.0",
46
- "grunt-karma": "^4.0.0",
44
+ "grunt-cli": "^1.4.3",
45
+ "grunt-contrib-clean": "^2.0.0",
46
+ "grunt-contrib-watch": "^1.1.0",
47
+ "grunt-eslint": "^24.0.0",
48
+ "grunt-karma": "^4.0.2",
47
49
  "grunt-mocha-test": "^0.13.3",
48
- "grunt-webpack": "^4.0.2",
49
- "istanbul-instrumenter-loader": "^1.0.0",
50
+ "grunt-webpack": "^5.0.0",
51
+ "istanbul-instrumenter-loader": "^3.0.1",
50
52
  "jasmine-core": "^2.4.1",
51
- "karma": "^6.3.2",
52
- "karma-chrome-launcher": "^3.1.0",
53
- "karma-firefox-launcher": "^2.1.0",
53
+ "karma": "^6.3.17",
54
+ "karma-chrome-launcher": "^3.1.1",
55
+ "karma-firefox-launcher": "^2.1.2",
54
56
  "karma-jasmine": "^1.1.1",
55
57
  "karma-jasmine-ajax": "^0.1.13",
56
58
  "karma-safari-launcher": "^1.0.0",
@@ -58,24 +60,26 @@
58
60
  "karma-sinon": "^1.0.5",
59
61
  "karma-sourcemap-loader": "^0.3.8",
60
62
  "karma-webpack": "^4.0.2",
61
- "load-grunt-tasks": "^3.5.2",
62
- "minimist": "^1.2.0",
63
+ "load-grunt-tasks": "^5.1.0",
64
+ "minimist": "^1.2.6",
63
65
  "mocha": "^8.2.1",
64
66
  "sinon": "^4.5.0",
65
67
  "terser-webpack-plugin": "^4.2.3",
66
- "typescript": "^4.0.5",
68
+ "typescript": "^4.6.3",
67
69
  "url-search-params": "^0.10.0",
68
70
  "webpack": "^4.44.2",
69
71
  "webpack-dev-server": "^3.11.0"
70
72
  },
71
73
  "browser": {
72
- "./lib/adapters/http.js": "./lib/adapters/xhr.js"
74
+ "./lib/adapters/http.js": "./lib/adapters/xhr.js",
75
+ "./lib/defaults/env/FormData.js": "./lib/helpers/null.js"
73
76
  },
74
77
  "jsdelivr": "dist/axios.min.js",
75
78
  "unpkg": "dist/axios.min.js",
76
79
  "typings": "./index.d.ts",
77
80
  "dependencies": {
78
- "follow-redirects": "^1.14.8"
81
+ "follow-redirects": "^1.14.9",
82
+ "form-data": "^4.0.0"
79
83
  },
80
84
  "bundlesize": [
81
85
  {
@@ -1,19 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * A `Cancel` is an object that is thrown when an operation is canceled.
5
- *
6
- * @class
7
- * @param {string=} message The message.
8
- */
9
- function Cancel(message) {
10
- this.message = message;
11
- }
12
-
13
- Cancel.prototype.toString = function toString() {
14
- return 'Cancel' + (this.message ? ': ' + this.message : '');
15
- };
16
-
17
- Cancel.prototype.__CANCEL__ = true;
18
-
19
- module.exports = Cancel;
@@ -1,18 +0,0 @@
1
- 'use strict';
2
-
3
- var enhanceError = require('./enhanceError');
4
-
5
- /**
6
- * Create an Error with the specified message, config, error code, request and response.
7
- *
8
- * @param {string} message The error message.
9
- * @param {Object} config The config.
10
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
11
- * @param {Object} [request] The request.
12
- * @param {Object} [response] The response.
13
- * @returns {Error} The created error.
14
- */
15
- module.exports = function createError(message, config, code, request, response) {
16
- var error = new Error(message);
17
- return enhanceError(error, config, code, request, response);
18
- };
@@ -1,43 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * Update an Error with the specified config, error code, and response.
5
- *
6
- * @param {Error} error The error to update.
7
- * @param {Object} config The config.
8
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
9
- * @param {Object} [request] The request.
10
- * @param {Object} [response] The response.
11
- * @returns {Error} The error.
12
- */
13
- module.exports = function enhanceError(error, config, code, request, response) {
14
- error.config = config;
15
- if (code) {
16
- error.code = code;
17
- }
18
-
19
- error.request = request;
20
- error.response = response;
21
- error.isAxiosError = true;
22
-
23
- error.toJSON = function toJSON() {
24
- return {
25
- // Standard
26
- message: this.message,
27
- name: this.name,
28
- // Microsoft
29
- description: this.description,
30
- number: this.number,
31
- // Mozilla
32
- fileName: this.fileName,
33
- lineNumber: this.lineNumber,
34
- columnNumber: this.columnNumber,
35
- stack: this.stack,
36
- // Axios
37
- config: this.config,
38
- code: this.code,
39
- status: this.response && this.response.status ? this.response.status : null
40
- };
41
- };
42
- return error;
43
- };