# Get data using Axios, CORS error

**URL:** <http://forum.companieshouse.gov.uk/t/get-data-using-axios-cors-error/3161>\
**Category:** API Question\
**Created:** [July 10, 2020, 10:34am UTC](http://forum.companieshouse.gov.uk/t/get-data-using-axios-cors-error/3161 "2020-07-10T10:34:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![eusebiub](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/e/258eb7/32.png) [@eusebiub](http://forum.companieshouse.gov.uk/u/eusebiub)\
**Post date:** [July 10, 2020, 10:34am UTC](http://forum.companieshouse.gov.uk/t/get-data-using-axios-cors-error/3161/1 "2020-07-10T10:34:34Z")

</div>

Hi,

I try to make a search aria with data from this API, for that I am using VueJs with axios. I read some posts from here but I still haven’t managed to make it work.

I am using artisan serve with a custom url like [http://example.local](http://example.local) , on port 80.

This is my code, where in my variables I have companies house url and my api key.  
In Authorised JavaScript domains I have both with .local and .local:80

```
  axios
    .get(this.$companiesHouseUrl, {
      params: {
        q: this.search_for_company
      },
      headers: {
        Authorization: "Basic " + btoa(this.$companiesHouseKey + ":")
      }
    })
    .then(response => {
      console.log("Response:", response);
    })
    .catch(e => {
      console.log("Error:", e);
    });

```

Access to XMLHttpRequest at ‘[https://api.companieshouse.gov.uk/?q=test](https://api.companieshouse.gov.uk/?q=test)’ from origin ‘[http://example.local](http://example.local)’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

**UPDATE:**  
I try from my live domain.

- in JavaScript domains I use both URL and URL:80
- add ‘Content-Type’: ‘application/json’ to headers ,or ‘text/json’
- add ‘Access-Control-Allow-Origin’: ‘\*’ and ‘Content-Type’: ‘application/json’ to headers
- add ‘Origin’: ‘myURL’
- if I remove Headers, no CORS error but error for auth

I didn’t find the solution yet…

**UPDATE 2 (SOLVED)**

- I found out what I was doing wrong… my $companiesHouseUrl was the  
main url so I change the url: _this.$companiesHouseUrl + ‘search/companies’_
