I'm trying to setup an API Gateway REST API that prompts a Lambda function and returns some items from a DynamoDB table.
When I test the API in the AWS API Gateway console I am getting the correct data back, but getting a Unexpected end of JSON input
error trying in JavaScript (just trying in JS Fiddle).
Here is my fetch function:
function fetchData(){
fetch("https://abcd1234.execute-api.region.amazonaws.com/stage/product?productId=1234"
).then(response => {
return response.json()
}).then(jsonData => {
console.log('success:', jsonData)
}).catch(e => {
console.log('error:', e.message)
return e
})
}
It's a get method in the Lambda function and I'm newer to this, so not sure what I'm doing wrong. If it was a CORS issue would I get a different message back?