So I have the following code snippet for carrying out a get request authenticated with a token to an API:
<script>
$.ajax({
url: "<API URL>",
type: 'GET',
headers: {"X-Api-Key": "<API Key>"}
});
</script>
The issue is that the API doesn't seem to actually receive the API key data. I get back a MissingAuthenticationTokenException.
Moreover, when I look at the raw request data in the browser I see:
Access-Control-Request-Method: GET
Access-Control-Request-Headers: x-api-key
You'll notice it lists x-api-key but doesn't seem to show any value assigned to it.
In contrast, on the command line I make successful GET calls with the following command:
curl -X GET -H 'X-Api-Key: <API KEY>' '<API URL>'
How can I alter my script to correctly pass the header data to the API?