JSFiddle - React, Tailwind, and code Playground

by Adrian Mejias

HTML

<button type="button" id="callOtherDomain">
test
</button>

JavaScript

function handler(status) {
  console.log('handler', status)
}

function callOtherDomain() {
  let invocation = new XMLHttpRequest();
  let url = 'https://uat-alp-api.eroms.works/api/v1/restricted/findsupplierandservicelocation';
  url += '?api_key=2FFED9D9-AB4C-4B1E-814E-685756E4280E';
  const body = '<?xml version="1.0"?><person><name>Arun</name></person>';
  if (invocation) {
    invocation.open('POST', url, true);
    invocation.setRequestHeader('X-PINGOTHER', 'pingpong');
    invocation.setRequestHeader('Content-Type', 'application/xml');
    invocation.onreadystatechange = handler;
    invocation.send(body);
  }
}
document.getElementById('callOtherDomain').onclick = callOtherDomain;