# Javascript: Getting Started

**URL:** <http://forum.companieshouse.gov.uk/t/javascript-getting-started/3069>\
**Category:** API Question\
**Created:** [June 3, 2020, 11:37am UTC](http://forum.companieshouse.gov.uk/t/javascript-getting-started/3069 "2020-06-03T11:37:07Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![orensetz](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/o/848f3c/32.png) [@orensetz](http://forum.companieshouse.gov.uk/u/orensetz)\
**Post date:** [June 5, 2020, 2:17pm UTC](http://forum.companieshouse.gov.uk/t/javascript-getting-started/3069/6 "2020-06-05T14:17:14Z")

</div>

@voracityemail I want to thank you for your help, patience and time invested in your responses. I was panicking because of time pressure hence the lazy requests but once I slowed down and [did some reading](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) I managed to find the solution. I needed to add an origin in the header. This snippet now returns the company information I need:

```
var url = 'https://api.companieshouse.gov.uk/company/12345678';
var key = 'MyApiKey';
var headers = new Headers ({
  'Authorization': 'Basic ' + btoa(key),
  'Content-Type': 'text/json',
  'Origin': 'MyOriginUrl'
});
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);
});

```

Thanks again! I could not have done it without you! 😊

---

_[View the full topic](http://forum.companieshouse.gov.uk/t/javascript-getting-started/3069)._
