0
I am trying to consume an API via XHR and Javascript that comes from SAP HANNA and it is returning these errors:
The funny thing is that with Postman it returns me the values, but with JS and XML it gives the above error..
Follow the simple code:
let xhr = new XMLHttpRequest();
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);
Are you complaining about Cross-Origin, tried to add in header?
– Ricardo Pontual
Take a look at this answer here: https://answall.com/a/126341/3999
– Laerte