src-old/utilities/http.js
function processBody(opts, body) {
  if (body === undefined) {
    return '';
  }
  const handlers = Object.assign({}, serializers, opts.serializers);
  const headers = typeof opts.headers === 'object' ? opts.headers : {};
  const contentType = Object.keys(headers).reduce((type, header) => {
    if (typeof type === 'string') {
      return type;
    }
    if (
      header.match(/^content-type$/i) &&
      typeof headers[header] === 'string'
    ) {
      return headers[header].toLowerCase();
    }
    return type;
  }, undefined);

  const handler = handlers[contentType];

  if (typeof handler === 'function') {
    return String(handler(body));
  }
  if (typeof body === 'object') {
    return JSON.stringify(body);
  }
  return String(body);
}
function processBody(opts, body) {
  if (body === undefined) {
    return '';
  }
  const handlers = Object.assign({}, serializers, opts.serializers);
  const headers = typeof opts.headers === 'object' ? opts.headers : {};
  const contentType = Object.keys(headers).reduce((type, header) => {
    if (typeof type === 'string') {
      return type;
    }
    if (
      header.match(/^content-type$/i) &&
      typeof headers[header] === 'string'
    ) {
      return headers[header].toLowerCase();
    }
    return type;
  }, undefined);

  const handler = handlers[contentType];

  if (typeof handler === 'function') {
    return String(handler(body));
  }
  if (typeof body === 'object') {
    return JSON.stringify(body);
  }
  return String(body);
}
function processBody ( opts , body ) { if ( body === undefined ) { return '' ; } const handlers = Object . assign ( { } , serializers , opts . serializers ) ; const headers = typeof opts . headers === 'object' ? opts . headers : { } ; const contentType = Object . keys ( headers ) . reduce ( ( type , header ) => { if ( typeof type === 'string' ) { return type ; } if ( header . match ( / ^content-type$ / i ) && typeof headers [ header ] === 'string' ) { return headers [ header ] . toLowerCase ( ) ; } return type ; } , undefined ) ; const handler = handlers [ contentType ] ; if ( typeof handler === 'function' ) { return String ( handler ( body ) ) ; } if ( typeof body === 'object' ) { return JSON . stringify ( body ) ; } return String ( body ) ; }
Converts the body value to a string using optional serializers
@param {*} opts
@param {*} body
Converts the body value to a string using optional serializers