0

I create simple google chrome extension and I get JSON data but this error is generated

dashboard.html:1 Access to XMLHttpRequest at 'https://humane-like-developer-edition.ap4.force.com/services/apexrest/SessionHuman' from origin 'chrome-extension://dgbedclgdamcknolmpacbbigocadoiko' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

This is my code

var HttpClient=function()
{
    this.get=function(aUrl,aCallback)
    {
        var anHttpRequest=new XMLHttpRequest();
        anHttpRequest.onreadystatechange=function()
        {
            if(anHttpRequest.readyState==4 && anHttpRequest.status==200)
            {
                aCallback(anHttpRequest.responseText);
            }
        }
        anHttpRequest.open("GET",aUrl,true);
        anHttpRequest.send(null);
    }
}
var theurl='https://humane-like-developer-edition.ap4.force.com/services/apexrest/SessionHuman';
var client=new HttpClient();
client.get(theurl,function(response){
alert(response);
Daut
  • 2,537
  • 1
  • 19
  • 32
Vishal Sharma
  • 1,051
  • 2
  • 8
  • 15
  • Possible duplicate of [Understanding CORS](https://stackoverflow.com/questions/25845203/understanding-cors) – Daniel W. Oct 29 '18 at 09:25

1 Answers1

0

No 'Access-Control-Allow-Origin' header is present on the requested resource.

The requested resource must respond an Access-Control-Allowed-Origin header matching your Origin request header.

If it is a public API you should respond with *. Note: Protocol is type of the response if it is not *, multiple values are not allowed, as well as wildcards are not allowed.

Daniel W.
  • 31,164
  • 13
  • 93
  • 151