question

nagesh avatar image
nagesh asked Frank Faustino Deactivated edited

Unable to access clover apis from front end angular js web application getting CORS Issue

We are building frontend application for clover merchants
so unable access the clover api's
getting cors issue
please provide the solution to access the services
7 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

c716524 avatar image c716524 commented ·

Hi, I have posted a similar question, but it is awaiting moderation from the Clover team, therefore not visible yet. Can you explain in more detail what problem you are experiencing? Maybe it is the same problem.

0 Likes 0 ·
chanel avatar image chanel commented ·

Hi @nagesh, in order to provide you with a complete answer, we'll need some extra information. For instance, we'll need a code snippet, what you expect the snippet to do and the full error message in question. Please see our Guide to Asking Questions for more detail.

0 Likes 0 ·
nagesh avatar image nagesh commented ·
Hi thanks for the response <br>am trying to run the below code from front end with out using any backend server<br>getting CORS issue <br><br>

var data = null;

var xhr = new XMLHttpRequest();

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://apisandbox.dev.clover.com/v3/merchants/9C0G0TBK9QJRY?access_token=REDACTED");
xhr.setRequestHeader("accept", "application/json");

xhr.send(data);
0 Likes 0 ·
c716524 avatar image c716524 nagesh commented ·

Did you check this URL using e.g. Postman or curl? Does it work? (they do not implement the same origin policy like browsers). BTW: you should not post sensitive data like access tokens in this forum

0 Likes 0 ·
nagesh avatar image nagesh c716524 commented ·

Yes I tried in Postman and it works. You are right..shouldnt be posting sensitive token data..apologies. Coming back to original question, how or what should I do to invoke clover api directly from UI without getting CORS issue. Please help! Thanks in Advance!!
Waiting for your response!

0 Likes 0 ·
Show more comments
nagesh avatar image nagesh commented ·
Yes I tried in Postman and it works. You are right..shouldnt be posting sensitive token data..apologies. Coming back to original question, how or what should I do to invoke clover api directly from UI without getting CORS issue. Please help! Thanks in Advance!!
0 Likes 0 ·

1 Answer

Frank Faustino avatar image
Frank Faustino Deactivated answered Frank Faustino Deactivated edited
Hi nagesh,

In order to make REST API calls from your client-side app, please verify that you have specified the Site URL and CORS Domain for your app in the Developer Dashboard (Settings > Web Configuration).

Additionally, I noticed in your attached screenshot that your app is just an HTML file, have you tried serving the HTML using a local web server? How are you retrieving the access token?
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community