source: imaps-frontend/node_modules/axios/lib/core/transformData.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 778 bytes
Line 
1'use strict';
2
3import utils from './../utils.js';
4import defaults from '../defaults/index.js';
5import AxiosHeaders from '../core/AxiosHeaders.js';
6
7/**
8 * Transform the data for a request or a response
9 *
10 * @param {Array|Function} fns A single function or Array of functions
11 * @param {?Object} response The response object
12 *
13 * @returns {*} The resulting transformed data
14 */
15export default function transformData(fns, response) {
16 const config = this || defaults;
17 const context = response || config;
18 const headers = AxiosHeaders.from(context.headers);
19 let data = context.data;
20
21 utils.forEach(fns, function transform(fn) {
22 data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
23 });
24
25 headers.normalize();
26
27 return data;
28}
Note: See TracBrowser for help on using the repository browser.