Hello, I would appreciate if you can help me with the following.
I am trying to call this API but I keep getting this error: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://app.pingboard.com/oauth/token?grant_type=client_credentials. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
var request = new XMLHttpRequest();
request.open('POST', 'https://app.pingboard.com/oauth/token?grant_type=client_credentials
');
request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
request.onreadystatechange = function () {
if (this.readyState === 4) {
console.log('Status:', this.status);
console.log('Headers:', this.getAllResponseHeaders());
console.log('Body:', this.responseText);
}
};
var body = "client_id=9jK&client_secret=Bwg";
request.send(body);
I have the script in a main.js file and I linked to it in an index.html file then I run this file using the live server extension in visual code. Is this possible or am I making a mistake somewhere, any help or pointers will really help. Thanks.