Command line utility to launch Express local API for claudia-api-builder. Test drive your lambda functions before deployment (https://www.npmjs.com/package/claudia-local-api)
Create a simple Claudia API with Claudia API Builder.
Include a route that handles a POST request.
Start the API with claudia-local-api --api-module ./entry_point_file.js.
With cURL, Postman, Insomnia, or some REST tool, do a POST to the route from step 2 and give it a Content-Type of application/x-www-form-urlencoded then add a body of foo=bar&baz=45.
In the request handler function request.post is an empty object. Expected request.post to equal { foo: "bar", baz: 45 }.
I think this is caused by using bodyParser.urlencoded(...), which will is middleware that will cause Express to parse the POST body into a JSON object before Claudia has a chance to handle it.
In the context of an AWS Lambda that is connected to API Gateway, this extra parsing step does not happen. Claudia gets the raw body as a string and not as a JSON object.
Steps to reproduce
claudia-local-api --api-module ./entry_point_file.js
.Content-Type
ofapplication/x-www-form-urlencoded
then add a body offoo=bar&baz=45
.request.post
is an empty object. Expectedrequest.post
to equal{ foo: "bar", baz: 45 }
.I think this is caused by using
bodyParser.urlencoded(...)
, which will is middleware that will cause Express to parse the POST body into a JSON object before Claudia has a chance to handle it.In the context of an AWS Lambda that is connected to API Gateway, this extra parsing step does not happen. Claudia gets the raw body as a string and not as a JSON object.