Hi,
This is very clearly something I am doing wrong, rather than an issue with the API. I am trying a very basic fetch in Node to stream filing information.
I have tried cURL and all works great, but when I put it in my application I can’t seem to get it to work. There are no errors, and it’s returning status of 200.
This is my very simple code:-
const base64 = require('base-64');
const url = 'https://stream.companieshouse.gov.uk/filings';
const streamKey = 'my-key';
const headers = new Headers();
headers.set("Authorization","Basic " + base64.encode(streamKey+":"));
fetch(url, {
headers: headers,
})
.then((response) => {
console.log(response);
return response.json()
})
.then(data => {
console.log(data);
})
.catch((error) => {
console.log(error);
})
And this is what I am seeing in the response where I have logged above:-
aborted: false,
rangeRequested: false,
timingAllowPassed: true,
requestIncludesCredentials: true,
type: 'default',
status: 200,
timingInfo: {
startTime: 99.316304,
redirectStartTime: 0,
redirectEndTime: 0,
postRedirectStartTime: 99.316304,
finalServiceWorkerStartTime: 0,
finalNetworkResponseStartTime: 0,
finalNetworkRequestStartTime: 0,
endTime: 0,
encodedBodySize: 671,
decodedBodySize: 0,
finalConnectionTimingInfo: null
},
cacheState: '',
statusText: 'OK',
headersList: HeadersList {
cookies: null,
[Symbol(headers map)]: [Map],
[Symbol(headers map sorted)]: null
},
urlList: [ URL {} ],
body: { stream: undefined }
Clearly I am doing something stupid here… Can anyone see what I might be doing wrong?