...**/!(*.map|*.min.js)Size
Gzip
Dependencies
Publish
Install
@@ -302,6 +302,7 @@ | |||
| 302 | silentJSONParsing?: boolean; | 302 | silentJSONParsing?: boolean; |
| 303 | forcedJSONParsing?: boolean; | 303 | forcedJSONParsing?: boolean; |
| 304 | clarifyTimeoutError?: boolean; | 304 | clarifyTimeoutError?: boolean; |
| 305 | legacyInterceptorReqResOrdering?: boolean; | ||
| 305 | } | 306 | } |
| 306 | 307 | ||
| 307 | interface GenericAbortSignal { | 308 | interface GenericAbortSignal { |
@@ -8,6 +8,7 @@ | |||
| 8 | import buildFullPath from './buildFullPath.js'; | 8 | import buildFullPath from './buildFullPath.js'; |
| 9 | import validator from '../helpers/validator.js'; | 9 | import validator from '../helpers/validator.js'; |
| 10 | import AxiosHeaders from './AxiosHeaders.js'; | 10 | import AxiosHeaders from './AxiosHeaders.js'; |
| 11 | import transitionalDefaults from '../defaults/transitional.js'; | ||
| 11 | 12 | ||
| 12 | const validators = validator.validators; | 13 | const validators = validator.validators; |
| 13 | 14 | ||
@@ -80,7 +81,8 @@ | |||
| 80 | validator.assertOptions(transitional, { | 81 | validator.assertOptions(transitional, { |
| 81 | silentJSONParsing: validators.transitional(validators.boolean), | 82 | silentJSONParsing: validators.transitional(validators.boolean), |
| 82 | forcedJSONParsing: validators.transitional(validators.boolean), | 83 | forcedJSONParsing: validators.transitional(validators.boolean), |
| 83 | clarifyTimeoutError: validators.transitional(validators.boolean) | 84 | clarifyTimeoutError: validators.transitional(validators.boolean), |
| 85 | legacyInterceptorReqResOrdering: validators.transitional(validators.boolean) | ||
| 84 | }, false); | 86 | }, false); |
| 85 | } | 87 | } |
| 86 | 88 | ||
@@ -139,7 +141,14 @@ | |||
| 139 | 141 | ||
| 140 | synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous; | 142 | synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous; |
| 141 | 143 | ||
| 142 | requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected); | 144 | const transitional = config.transitional || transitionalDefaults; |
| 145 | const legacyInterceptorReqResOrdering = transitional && transitional.legacyInterceptorReqResOrdering; | ||
| 146 | |||
| 147 | if (legacyInterceptorReqResOrdering) { | ||
| 148 | requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected); | ||
| 149 | } else { | ||
| 150 | requestInterceptorChain.push(interceptor.fulfilled, interceptor.rejected); | ||
| 151 | } | ||
| 143 | }); | 152 | }); |
| 144 | 153 | ||
| 145 | const responseInterceptorChain = []; | 154 | const responseInterceptorChain = []; |
@@ -247,14 +247,14 @@ | |||
| 247 | 247 | ||
| 248 | if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) { | 248 | if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) { |
| 249 | throw Object.assign( | 249 | throw Object.assign( |
| 250 | new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request), | 250 | new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request, err && err.response), |
| 251 | { | 251 | { |
| 252 | cause: err.cause || err | 252 | cause: err.cause || err |
| 253 | } | 253 | } |
| 254 | ) | 254 | ) |
| 255 | } | 255 | } |
| 256 | 256 | ||
| 257 | throw AxiosError.from(err, err && err.code, config, request); | 257 | throw AxiosError.from(err, err && err.code, config, request, err && err.response); |
| 258 | } | 258 | } |
| 259 | } | 259 | } |
| 260 | } | 260 | } |
@@ -11,5 +11,10 @@ | |||
| 11 | // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL). | 11 | // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL). |
| 12 | // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed | 12 | // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed |
| 13 | // by any combination of letters, digits, plus, period, or hyphen. | 13 | // by any combination of letters, digits, plus, period, or hyphen. |
| 14 | if (typeof url !== 'string') { | ||
| 15 | return false; | ||
| 16 | } | ||
| 17 | |||
| 14 | return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url); | 18 | return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url); |
| 15 | } | 19 | } |
| 20 | |||
@@ -1,9 +1,10 @@ | |||
| 1 | 'use strict'; | 1 | "use strict"; |
| 2 | 2 | ||
| 3 | import utils from '../utils.js'; | 3 | import utils from "../utils.js"; |
| 4 | import AxiosHeaders from "./AxiosHeaders.js"; | 4 | import AxiosHeaders from "./AxiosHeaders.js"; |
| 5 | 5 | ||
| 6 | const headersToObject = (thing) => thing instanceof AxiosHeaders ? { ...thing } : thing; | 6 | const headersToObject = (thing) => |
| 7 | thing instanceof AxiosHeaders ? { ...thing } : thing; | ||
| 7 | 8 | ||
| 8 | /** | 9 | /** |
| 9 | * Config-specific merge-function which creates a new config-object | 10 | * Config-specific merge-function which creates a new config-object |
@@ -92,14 +93,27 @@ | |||
| 92 | socketPath: defaultToConfig2, | 93 | socketPath: defaultToConfig2, |
| 93 | responseEncoding: defaultToConfig2, | 94 | responseEncoding: defaultToConfig2, |
| 94 | validateStatus: mergeDirectKeys, | 95 | validateStatus: mergeDirectKeys, |
| 95 | headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true) | 96 | headers: (a, b, prop) => |
| 97 | mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true), | ||
| 96 | }; | 98 | }; |
| 97 | 99 | ||
| 98 | utils.forEach(Object.keys({ ...config1, ...config2 }), function computeConfigValue(prop) { | ||
| 99 | const merge = mergeMap[prop] || mergeDeepProperties; | ||
| 100 | const configValue = merge(config1[prop], config2[prop], prop); | ||
| 101 | (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue); | ||
| 102 | }); | 100 | utils.forEach( |
| 101 | Object.keys({ ...config1, ...config2 }), | ||
| 102 | function computeConfigValue(prop) { | ||
| 103 | if ( | ||
| 104 | prop === "__proto__" || | ||
| 105 | prop === "constructor" || | ||
| 106 | prop === "prototype" | ||
| 107 | ) | ||
| 108 | return; | ||
| 109 | const merge = utils.hasOwnProp(mergeMap, prop) | ||
| 110 | ? mergeMap[prop] | ||
| 111 | : mergeDeepProperties; | ||
| 112 | const configValue = merge(config1[prop], config2[prop], prop); | ||
| 113 | (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || | ||
| 114 | (config[prop] = configValue); | ||
| 115 | }, | ||
| 116 | ); | ||
| 103 | 117 | ||
| 104 | return config; | 118 | return config; |
| 105 | } | 119 | } |
@@ -615,6 +615,9 @@ | |||
| 615 | 615 | ||
| 616 | // throw ETIMEDOUT error instead of generic ECONNABORTED on request timeouts | 616 | // throw ETIMEDOUT error instead of generic ECONNABORTED on request timeouts |
| 617 | clarifyTimeoutError: false, | 617 | clarifyTimeoutError: false, |
| 618 | |||
| 619 | // use the legacy interceptor request/response ordering | ||
| 620 | legacyInterceptorReqResOrdering: true, // default | ||
| 618 | }, | 621 | }, |
| 619 | 622 | ||
| 620 | env: { | 623 | env: { |
@@ -1065,7 +1068,7 @@ | |||
| 1065 | 1068 | ||
| 1066 | ### URLSearchParams | 1069 | ### URLSearchParams |
| 1067 | 1070 | ||
| 1068 | By default, axios serializes JavaScript objects to `JSON`. To send data in the [`application/x-www-form-urlencoded` format](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST) instead, you can use the [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) API, which is [supported](http://www.caniuse.com/#feat=urlsearchparams) in the vast majority of browsers,and [ Node](https://nodejs.org/api/url.html#url_class_urlsearchparams) starting with v10 (released in 2018). | 1071 | By default, axios serializes JavaScript objects to `JSON`. To send data in the [`application/x-www-form-urlencoded`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST) format instead, you can use the [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) API, which is [supported](http://www.caniuse.com/#feat=urlsearchparams) in the vast majority of browsers, and [Node](https://nodejs.org/api/url.html#url_class_urlsearchparams) starting with v10 (released in 2018). |
| 1069 | 1072 | ||
| 1070 | ```js | 1073 | ```js |
| 1071 | const params = new URLSearchParams({ foo: "bar" }); | 1074 | const params = new URLSearchParams({ foo: "bar" }); |
@@ -1184,7 +1187,7 @@ | |||
| 1184 | 1187 | ||
| 1185 | const form = new FormData(); | 1188 | const form = new FormData(); |
| 1186 | form.append("my_field", "my value"); | 1189 | form.append("my_field", "my value"); |
| 1187 | form.append("my_buffer", new Buffer(10)); | 1190 | form.append("my_buffer", Buffer.alloc(10)); |
| 1188 | form.append("my_file", fs.createReadStream("/foo/bar.jpg")); | 1191 | form.append("my_file", fs.createReadStream("/foo/bar.jpg")); |
| 1189 | 1192 | ||
| 1190 | axios.post("https://example.com", form); | 1193 | axios.post("https://example.com", form); |
@@ -1225,7 +1228,7 @@ | |||
| 1225 | axios | 1228 | axios |
| 1226 | .post( | 1229 | .post( |
| 1227 | "https://httpbin.org/post", | 1230 | "https://httpbin.org/post", |
| 1228 | { x: 1, buf: new Buffer(10) }, | 1231 | { x: 1, buf: Buffer.alloc(10) }, |
| 1229 | { | 1232 | { |
| 1230 | headers: { | 1233 | headers: { |
| 1231 | "Content-Type": "multipart/form-data", | 1234 | "Content-Type": "multipart/form-data", |
@@ -332,6 +332,7 @@ | |||
| 332 | silentJSONParsing?: boolean; | 332 | silentJSONParsing?: boolean; |
| 333 | forcedJSONParsing?: boolean; | 333 | forcedJSONParsing?: boolean; |
| 334 | clarifyTimeoutError?: boolean; | 334 | clarifyTimeoutError?: boolean; |
| 335 | legacyInterceptorReqResOrdering?: boolean; | ||
| 335 | } | 336 | } |
| 336 | 337 | ||
| 337 | export interface GenericAbortSignal { | 338 | export interface GenericAbortSignal { |
Publish
Install