src-old/utilities/http.js
function processData(res, data, options) {
  const handlers = Object.assign({}, deserializers, options.deserializers);
  const contentType = res.headers['content-type'];
  const types = typeof contentType === 'string' ? contentType.split(';') : [];

  // if there are no content types, return the data unmodified
  if (!types.length) {
    return data;
  }

  return types.reduce((d, type) => {
    try {
      const t = type.toLocaleLowerCase().trim();
      const handler = handlers[t];

      if (d instanceof Error || typeof handler !== 'function') {
        return d;
      }
      return handler(d);
    } catch (error) {
      return error;
    }
  }, data);
}
function processData(res, data, options) {
  const handlers = Object.assign({}, deserializers, options.deserializers);
  const contentType = res.headers['content-type'];
  const types = typeof contentType === 'string' ? contentType.split(';') : [];

  // if there are no content types, return the data unmodified
  if (!types.length) {
    return data;
  }

  return types.reduce((d, type) => {
    try {
      const t = type.toLocaleLowerCase().trim();
      const handler = handlers[t];

      if (d instanceof Error || typeof handler !== 'function') {
        return d;
      }
      return handler(d);
    } catch (error) {
      return error;
    }
  }, data);
}
function processData ( res , data , options ) { const handlers = Object . assign ( { } , deserializers , options . deserializers ) ; const contentType = res . headers [ 'content-type' ] ; const types = typeof contentType === 'string' ? contentType . split ( ';' ) : [ ] ; // if there are no content types, return the data unmodified if ( ! types . length ) { return data ; } return types . reduce ( ( d , type ) => { try { const t = type . toLocaleLowerCase ( ) . trim ( ) ; const handler = handlers [ t ] ; if ( d instanceof Error || typeof handler !== 'function' ) { return d ; } return handler ( d ) ; } catch ( error ) { return error ; } } , data ) ; }
Processes the response data based on content type using optional
deserializers
@param {*} res
@param {*} data
@param {*} options
Processes the response data based on content type using optional deserializers