How to structure REST API in Javascript

Hi, im a newbie to Moralis here, and im trying to use REST API to get token price like this:

var requesting = new XMLHttpRequest();‘GET’, ‘’, true);
requesting.setRequestHeader(“Content-Type”, “application/json”);
requesting.setRequestHeader(‘Authorization’, 'Basic ’ + window.btoa(‘x-api-key:myKeyHere’));

But im getting the error message: API KEY missing from x-api-key header

what am i doing wrong in setting API key in the headers?

I don’t think you need to wrap you API Key with window.btoa, try just

requesting.setReuestHeader('X-API-Key', <your-api-key>);