Hello community,
This is my first post here, so forgive me if it lacks information.
I’m building a simple website and I’m using Lambda Functions to send the content of a form to Mailgun. I’ve tested locally and it works, but when I deploy I keep getting an error from the Lambda Functions.
{
"errorType": "SyntaxError",
"errorMessage": "Unexpected end of JSON input",
"trace": [
"SyntaxError: Unexpected end of JSON input",
" at JSON.parse (<anonymous>)",
" at Runtime.n.handler (/var/task/src/test.js:1:1027)",
" at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)"
]
}
I’ve tried creating a simple function just to debug the JSON.parse problem, and I don’t know what I’m doing wrong, since it again worked locally.
My test function file looks like this:
exports.handler = function(event, context, callback) {
const data = JSON.parse(event.body)
console.log(data.name)
callback(null, {
statusCode: 200,
body: JSON.stringify(data.name),
})
}
Did anybody have this problem too?
Thanks