mirror of
https://github.com/axios/axios.git
synced 2026-04-15 15:36:19 +08:00
19 lines
504 B
JavaScript
19 lines
504 B
JavaScript
'use strict';
|
|
|
|
var utils = require('./utils');
|
|
|
|
/**
|
|
* Transform the data for a request or a response
|
|
*
|
|
* @param {Object|String} data The data to be transformed
|
|
* @param {Array} headers The headers for the request or response
|
|
* @param {Array|Function} fns A single function or Array of functions
|
|
* @returns {*} The resulting transformed data
|
|
*/
|
|
module.exports = function transformData(data, headers, fns) {
|
|
utils.forEach(fns, function (fn) {
|
|
data = fn(data, headers);
|
|
});
|
|
|
|
return data;
|
|
}; |