I have set AWS Usage Plan and attached a key to the API.
I have this code which throws 403 Forbidden.
fetch(myapi, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'x-api-key': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
}
})
.then(function(response) {
return response.json();
})
.then(function(json) {
return json;
});
where as when I run Curl with the same key on the same api, it returns 200 OK.
curl -i -H "x-api-key:xxxxxxxxxxxxxxxxxxxxxx" -X GET https://xxxxxxxx.execute-api.us-east-1.amazonaws.com/Stage/test.
What is going wrong with the Fetch API code?