LiquidPlanner Classic Forum
How to use LP API in JavaScript?
Hi,
I am trying to run this JS code from the doc:
https://developer.liquidplanner.com/reference#get_account
var data = JSON.stringify(false);
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://app.liquidplanner.com/api/v1/account");
xhr.send(data);
On running it on the browser, I get a prompt to enter username and password, after entering the credentials, I get the following error on local system and also on server after deploying:
Access to XMLHttpRequest at 'https://app.liquidplanner.com/api/v1/account' from origin 'http://localhost:3002' (https://myservername.com/) has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Is there any parameter configuration to be added on the xhr request to make it work?