The exact error that I am struggling with is "Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.".
I am trying to fetch JSON data using JavaScript from https://api.kraken.com/0/public/OHLC?pair=ETHEUR. I created a XMLHttpRequest object to do this, and specified GET as the type of request. This is supposedly a simple request, however the error says that a preflight request was sent. What is the reason for this behavior? That being said, to fix this error I tried to set a request header in which I specified '*' as the value for the Access-Control-Allow-Origin, yet I still get an error. I have looked through responses to similar questions as mine, but haven't been able to figure out how to solve the problem I am dealing with. This is probably due to still being very new to JavaScript. Either way, below is the code that I have written:
    var requestURL = 'https://api.kraken.com/0/public/OHLC?pair=ETHEUR'
    var request = new XMLHttpRequest();
    request.open('GET',requestURL,true);
    request.responseType = 'json';
    request.onload = function(){ 
        var data = request.response; 
        console.log(data); 
    }
    request.setRequestHeader('Access-Control-Allow-Origin','*');
    request.send(); 
 
     
    