0

My group and I are starting our first project, and ten minutes into API testing, I hit a wall and have been unable to create a successful access control header. Can anyone help me work through this error?

var userSearch = "chicken"


function apiCall() {

  var queryURL = "http://food2fork.com/api/search?key=3a4f22fb3ddd09f03521f9daf18117a1&q=" + userSearch; //+ "&sort=r"

 $.ajax({
    url: queryURL,
   method: "GET"
 }).done(function(response) {

      console.log(response);

 });
 };

apiCall();

"Failed to load http://food2fork.com/api/search?key=3a4f22fb3ddd09f03521f9daf18117a1&q=chicken: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access."

Whit W
  • 74
  • 10

1 Answers1

1

You need to use a reverse proxy to defeat CORS in browser. You can use a tool like this: CORS Proxy

Ian
  • 544
  • 3
  • 16