jQuery request to API

Hi

I am getting following error when sending request
Request header field Access-Control-Allow-Origin is not allowed by Access-Control-Allow-Headers in preflight

however i have allowed javascript domains in the application settings

Any of the following help?

If not try giving some more info about your case e.g. sample code, request sent, response / errors etc.
Chris

Hi Bilalits,

I had the same problem (using AngularJS). Finally fixed it. Here is my code in case you are still struggling (and for anyone else who finds the curl rather than JavaScript examples completely unhelpful).

   url = "https://api.companieshouse.gov.uk/search/companies/?q=" + name;
    		 
   $sce.trustAsResourceUrl(url);
    		 		
   var auth = btoa(API_KEY + ":");    <-- This is the important line!
    		 
   return $http({ method: 'GET', 
 	 	  dataType: "json",
  	 	  contentType: 'application/x-www-form-urlencoded; charset=utf-8',
  	          headers: {"Authorization": "Basic " + auth},
  	          xhrFields: { withCredentials: true },
              url:  url }).then(function (response) 
           {
  		// Do something with the data and return.
    			    
        }, function (response) 
          {    	  			
    	      // Failed -  log the error.
   	        });