JavaScript API request errors on Authorization

Hey, I keep getting errors when trying to do a search. {"error": "Invalid Authorization", "type": "ch:service"}

I have a “stream api key”

My basic fetch request is:

var url = `${string}` fetch(url, { method: 'GET', headers: { Accept: 'application/json', 'Content-Type': 'application/json', 'Authorization' : `Basic ${APIKEY}`, } });

The APIKEY var is what is provided by the service - my stream key basically.

Is there a step I am missing here to enable this to connect with javascript?

I have resolved this, there was two things wrong with what I was attempting. First of all I needed to base64 encode my API key, but it also needs noting that the Stream API key was not enough to get working. I need to set up a Rest API key in order to access the data I needed.