CORS Test

HTML

<button id="btn_1">derp</button>
<button id="btn_2">CORS enabled</button>
(siehe console)

JavaScript

document.getElementById("btn_1").addEventListener("click", function() {
            console.log('Das dashboard ist nicht CORS enabeld ...')
            var xhReq = new XMLHttpRequest();
            var url = "http://localhost:8081/metrics"
            xhReq.open("GET", url , true);
            xhReq.send(null);
            var serverResponse = xhReq.responseText;
            console.log(serverResponse);
        });

    
        document.getElementById("btn_2").addEventListener("click", function() {
            var xhReq = new XMLHttpRequest();
            console.log('... die Datenbank aber schon.')
            var url = "https://dirkk0.cloudant.com/test13"
            xhReq.open("GET", url , true);
            xhReq.send(null);
            var serverResponse = xhReq.responseText;
            console.log(serverResponse);
        });