Problem with Access-Control-Allow-Origin in XHR with Javascript

0

I'm trying to consume an API via XHR and Javascript that comes from SAP HANNA and it's returning these errors:

Thefunnythingisthatwiththepostmanitreturnsmethevalues,howeverwithJSandXMLitgivestheerrorabove..

Followthesimplecode:

letxhr=newXMLHttpRequest();xhr.withCredentials=true;xhr.addEventListener("readystatechange", function () {
        if (xhr.readyState === 4) {
          console.log(xhr.responseText);
        }
      });

    xhr.open("GET", "https://aliansce.apimanagement.us2.hana.ondemand.com/bot/v1/fatVenda.xsjs?Shop='BSC'&PeriodoAte=201807", true);
    xhr.setRequestHeader("Content-Type", "application/json");
    xhr.setRequestHeader("Apikey", "KEY");
    xhr.setRequestHeader("Authorization", "Basic AUTH=");
    xhr.setRequestHeader("cache-control", "no-cache");
    xhr.setRequestHeader("postman-token", "TOKEN");

    xhr.send(null);
    
asked by anonymous 03.09.2018 / 23:06

0 answers