I am trying to implement SendGrid through a Netlify serveless functions, however every time after submitting the form the function throws this error:
{
"errorType": "SyntaxError",
"errorMessage": "Unexpected token a in JSON at position 1",
"trace": [
"SyntaxError: Unexpected token a in JSON at position 1",
" at JSON.parse (<anonymous>)",
" at Runtime.exports.handler (/var/task/src/functions/sendmail.js:5:44)",
" at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)"
]
}
I have no idea what is wrong as from Netlify docs the event.body is a JSON string so why JSON.parse() is not working?