I've got the following JS which is attempting to return a value from an AWS API Gateway:
<script>
fetch("https://myapi/get")
.then(response => response.json())
.then(data => {
document.getElementById("website-counter").innerHTML = data.body
});
</script>
The API GW triggers a lambda function to get a value from a DynamoDB table. Im attempting to display the retuned value by
<p>
CV Website Views: <span id="website-counter"></span><br/>
</p>
However, the "website-counter" returns an undefined value, not the required DB value.
Also, Ive set the CORS headers in the Lambda function itself. If i access the direct link to the API from AWS console, i get the retuned value from dynamodb as expected.