@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 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! 