mirror of
https://github.com/tenrok/axios.git
synced 2026-06-02 16:04:10 +03:00
Adding HTTP status code for transformResponse (#4580)
* Adding HTTP status code for transformResponse * refs #1214 * Fix wrong argument for tranformResponse * Fix test wrong argument for tranformData * Add test case for transformData * Add test case for transformData (reference headers case) Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
@@ -8,14 +8,15 @@ var defaults = require('../defaults');
|
||||
*
|
||||
* @param {Object|String} data The data to be transformed
|
||||
* @param {Array} headers The headers for the request or response
|
||||
* @param {Number} status HTTP status code
|
||||
* @param {Array|Function} fns A single function or Array of functions
|
||||
* @returns {*} The resulting transformed data
|
||||
*/
|
||||
module.exports = function transformData(data, headers, fns) {
|
||||
module.exports = function transformData(data, headers, status, fns) {
|
||||
var context = this || defaults;
|
||||
/*eslint no-param-reassign:0*/
|
||||
utils.forEach(fns, function transform(fn) {
|
||||
data = fn.call(context, data, headers);
|
||||
data = fn.call(context, data, headers, status);
|
||||
});
|
||||
|
||||
return data;
|
||||
|
||||
Reference in New Issue
Block a user