src/transport-multipart-interceptor.js
function transformMessageToRequestMessage(message) {
  const newMessage = {
    info: message.info,
    hops: message.hops
  };

  let payload;
  if (message.payload === 'string') {
    payload = message.payload;
  } else if (message.payload instanceof stream.Stream) {
    payload = message.payload;
  } else {
    // expect that it is JSON
    payload = JSON.stringify(message.payload);
  }

  // make the message a form
  const formData = new FormData();
  if (message.info) {
    formData.append('info', JSON.stringify(message.info));
  }
  if (message.hops) {
    formData.append('hops', JSON.stringify(message.hops));
  }
  if (payload) {
    formData.append('payload', payload);
  }

  newMessage.payload = formData;

  return newMessage;
}
function transformMessageToRequestMessage(message) {
  const newMessage = {
    info: message.info,
    hops: message.hops
  };

  let payload;
  if (message.payload === 'string') {
    payload = message.payload;
  } else if (message.payload instanceof stream.Stream) {
    payload = message.payload;
  } else {
    // expect that it is JSON
    payload = JSON.stringify(message.payload);
  }

  // make the message a form
  const formData = new FormData();
  if (message.info) {
    formData.append('info', JSON.stringify(message.info));
  }
  if (message.hops) {
    formData.append('hops', JSON.stringify(message.hops));
  }
  if (payload) {
    formData.append('payload', payload);
  }

  newMessage.payload = formData;

  return newMessage;
}
function transformMessageToRequestMessage ( message ) { const newMessage = { info : message . info , hops : message . hops } ; let payload ; if ( message . payload === 'string' ) { payload = message . payload ; } else if ( message . payload instanceof stream . Stream ) { payload = message . payload ; } else { // expect that it is JSON payload = JSON . stringify ( message . payload ) ; } // make the message a form const formData = new FormData ( ) ; if ( message . info ) { formData . append ( 'info' , JSON . stringify ( message . info ) ) ; } if ( message . hops ) { formData . append ( 'hops' , JSON . stringify ( message . hops ) ) ; } if ( payload ) { formData . append ( 'payload' , payload ) ; } newMessage . payload = formData ; return newMessage ; }
Copies the fields 'info' and 'hops' into the new message.
Then create a formdata object containing 'info', 'hops' and 'payload'.
Stores the formdata object as the payload of the 'newMessage' object.
@param message The message to transform
@return newMessage The transformed message
Copies the fields info and hops into the new message . Then create a formdata object containing info hops and payload . Stores the formdata object as the payload of the newMessage object .