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();
requesting.open(‘GET’, ‘https://deep-index.moralis.io/api/v2/erc20/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2/price?chain=eth’, 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>);