diff options
author | Minteck <contact@minteck.org> | 2022-04-17 17:37:10 +0200 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-04-17 17:37:10 +0200 |
commit | 4081c2036a5af21519095da1b8b99c507b0fba93 (patch) | |
tree | fc95894e74c84d4d34c0d761837e8d6175829dd7 /node_modules/axios/lib/core/dispatchRequest.js | |
parent | 637ca7ba746c0241aaec79b79349d5dac4ec7408 (diff) | |
download | twilight-4081c2036a5af21519095da1b8b99c507b0fba93.tar.gz twilight-4081c2036a5af21519095da1b8b99c507b0fba93.tar.bz2 twilight-4081c2036a5af21519095da1b8b99c507b0fba93.zip |
Deprecation
Diffstat (limited to 'node_modules/axios/lib/core/dispatchRequest.js')
-rw-r--r-- | node_modules/axios/lib/core/dispatchRequest.js | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/node_modules/axios/lib/core/dispatchRequest.js b/node_modules/axios/lib/core/dispatchRequest.js deleted file mode 100644 index 36da48b..0000000 --- a/node_modules/axios/lib/core/dispatchRequest.js +++ /dev/null @@ -1,87 +0,0 @@ -'use strict'; - -var utils = require('./../utils'); -var transformData = require('./transformData'); -var isCancel = require('../cancel/isCancel'); -var defaults = require('../defaults'); -var Cancel = require('../cancel/Cancel'); - -/** - * Throws a `Cancel` if cancellation has been requested. - */ -function throwIfCancellationRequested(config) { - if (config.cancelToken) { - config.cancelToken.throwIfRequested(); - } - - if (config.signal && config.signal.aborted) { - throw new Cancel('canceled'); - } -} - -/** - * Dispatch a request to the server using the configured adapter. - * - * @param {object} config The config that is to be used for the request - * @returns {Promise} The Promise to be fulfilled - */ -module.exports = function dispatchRequest(config) { - throwIfCancellationRequested(config); - - // Ensure headers exist - config.headers = config.headers || {}; - - // Transform request data - config.data = transformData.call( - config, - config.data, - config.headers, - config.transformRequest - ); - - // Flatten headers - config.headers = utils.merge( - config.headers.common || {}, - config.headers[config.method] || {}, - config.headers - ); - - utils.forEach( - ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], - function cleanHeaderConfig(method) { - delete config.headers[method]; - } - ); - - var adapter = config.adapter || defaults.adapter; - - return adapter(config).then(function onAdapterResolution(response) { - throwIfCancellationRequested(config); - - // Transform response data - response.data = transformData.call( - config, - response.data, - response.headers, - config.transformResponse - ); - - return response; - }, function onAdapterRejection(reason) { - if (!isCancel(reason)) { - throwIfCancellationRequested(config); - - // Transform response data - if (reason && reason.response) { - reason.response.data = transformData.call( - config, - reason.response.data, - reason.response.headers, - config.transformResponse - ); - } - } - - return Promise.reject(reason); - }); -}; |