I’m trying to use Serverless to set up a basic REST API for a web app. I’ve written and tested my Lambda functions, and they all work perfectly (even with Serverless if I use the “invoke” command) and return the expected results. However, my problem starts when I add an HTTP event, particularly a post event. Here is how my serverless.yml file is set up:
functions:
getPlayers:
handler: getPlayers.getPlayers
events:
- http:
path: players
method: get
integration: lambda
addPlayer:
handler: addPlayer.addPlayer
events:
- http:
path: players
method: post
integration: lambda
deletePlayer:
handler: deletePlayer.deletePlayer
events:
- http:
path: players
method: delete
integration: lambda
I now have my getPlayers API call working correctly (had to add integration: lambda to make it work), but I cannot get addPlayer or deletePlayer to work. When I go to AWS console and test my addPlayer API directly, I get the following error:
{
"errorMessage": "Process exited before completing request"
}
I should not be getting these errors since I’m calling the callback() function correctly in my Lambda code. If I plug the exact same inputs into my Lambda function, I get the correct outputs, so something is clearly wrong with how Serverless is setting up my API. Does anyone have suggestions for how to fix this? I would really appreciate the help!