Cannot JSON.parse event.body

I’ve been working on a simple function that gets some data in a http POST, does some analysis and sends the results back. I got it working locally on my machine using serverless-offline but when it comes to deploying it I’m getting an error parsing the event.body.

Logging out the event.body it’s a string that looks like this:

----------------------------267253304929569989286258
Content-Disposition: form-data; name="text"

TEST
----------------------------267253304929569989286258--

so it makes sense that the parse is failing but I have no idea why this error it happening.
Any suggestions? I’ve tried a bunch of different things but am completely stumped.

Thanks in advance!

It looks like you’re posting data to the API endpoint from a multi-part HTML form. Are you doing that in your local environment too?

1 Like