# Advanced Search API Not Working Using Javascript

**URL:** <http://forum.companieshouse.gov.uk/t/advanced-search-api-not-working-using-javascript/5573>\
**Category:** API Question\
**Created:** [October 11, 2022, 1:17pm UTC](http://forum.companieshouse.gov.uk/t/advanced-search-api-not-working-using-javascript/5573 "2022-10-11T13:17:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fe\_dev](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/f/898d66/32.png) [@fe\_dev](http://forum.companieshouse.gov.uk/u/fe_dev)\
**Post date:** [October 11, 2022, 1:17pm UTC](http://forum.companieshouse.gov.uk/t/advanced-search-api-not-working-using-javascript/5573/1 "2022-10-11T13:17:51Z")

</div>

I am trying to access the advanced search from front end Javascript fetch(). This call works for all endpoints I have tried apart from the advanced search endpoint. Here is the code.

```
var url = 'https://api.company-information.service.gov.uk/advanced-search/companies?company_name_includes=vodaphone';

    var headers = new Headers({
      Authorization: "Basic " + btoa(API_KEY + ':'),
      "Content-Type": "text/json",
    });

    var obj = {
      mode: "cors",
      method: "GET",
      cache: "no-cache",
      headers: headers,
    };

    fetch(url, obj)
      .then((resp) => resp.json())
      .then((data) => console.log(data))
      .catch(function(err) {
        console.log(err);
      });

```

This code works for most endpoints for example ‘[https://api.company-information.service.gov.uk/search](https://api.company-information.service.gov.uk/search)’.

However when calling the ‘[https://api.company-information.service.gov.uk/advanced-search/companies?company\_name\_includes=vodaphone](https://api.company-information.service.gov.uk/advanced-search/companies?company_name_includes=vodaphone)’ endpoint I get a CORS error. However it isn’t a 401.

I have whitelisted my domain on my REST API key and there are no IP restrictions and as I say the authorization works for other endpoints so I’m not sure what I am missing here.

Does the advanced search have a different authorization method than the other endpoints. All endpoints work when performing the calls through Postman.

Many thanks
