function sendRequest(payload, contentType) {
  // Headers for the POST request to use
  const headers = {
    'Content-Type': contentType
  };

  if (contentType == 'base64') {
    headers['Content-Type'] = 'text/plain';
    headers['Content-Transfer-Encoding'] = 'base64';
  }

  fetch(url, {
    method: 'POST',
    headers: headers,
    body: payload
  })
  .then(response => response.json())
  .then(data => {
    document.querySelector('output').innerHTML = JSON.stringify(data);
  })
  .catch(err => {
    console.error(err);
  });
}
/**
 * Sends the request to the sever with a POST request, displays the response on
 * the page
 * @param {string} payload the encoded & prepared payload to send to the server
 * @param {string} contentType the content type to use when sending this payload
 */
Sends the request to the sever with a POST request, displays the response on
the page
@param {string} payload the encoded & prepared payload to send to the server
@param {string} contentType the content type to use when sending this payload
Sends the request to the sever with a POST request displays the response on the page @param { string } payload the encoded & prepared payload to send to the server @param { string } contentType the content type to use when sending this payload
function sendRequest(payload, contentType) {
  const headers = {
    'Content-Type': contentType
  };
  if (contentType == 'base64') {
    headers['Content-Type'] = 'text/plain';
    headers['Content-Transfer-Encoding'] = 'base64';
  }
  fetch(url, {
    method: 'POST',
    headers: headers,
    body: payload
  })
  .then(response => response.json())
  .then(data => {
    document.querySelector('output').innerHTML = JSON.stringify(data);
  })
  .catch(err => {
    console.error(err);
  });
}
function sendRequest ( payload , contentType ) { const headers = { 'Content-Type' : contentType } ; if ( contentType == 'base64' ) { headers [ 'Content-Type' ] = 'text/plain' ; headers [ 'Content-Transfer-Encoding' ] = 'base64' ; } fetch ( url , { method : 'POST' , headers : headers , body : payload } ) . then ( response => response . json ( ) ) . then ( data => { document . querySelector ( 'output' ) . innerHTML = JSON . stringify ( data ) ; } ) . catch ( err => { console . error ( err ) ; } ) ; }
Sends the request to the sever with a POST request, displays the response on
 the page
 @param {string} payload the encoded & prepared payload to send to the server
 @param {string} contentType the content type to use when sending this payload
Sends the request to the sever with a POST request displays the response on the page @param { string } payload the encoded & prepared payload to send to the server @param { string } contentType the content type to use when sending this payload
// Headers for the POST request to use