Amazon Web Services (AWS) - POST JSON to a Node.js Lambda Function using AWS console Test Event


by
Jeremy Canfield |
Updated: November 18 2024
| Amazon Web Services (AWS) articles
There are various way to POST JSON to one of your NodeJS AWS Lambda Functions.
- POST JSON to a NodeJS Lambda Function using AWS console Test Event (this article)
- POST JSON to a Lambda Function using cURL
- POST JSON to a Lambda Function using EventBridge Scheduler
Let's say you have a NodeJS Lambda Function, perhaps something like this. This is just a super simple example with no error handling to highlight the boilerplate markup needed to parse and return values from input.
export const handler = async (event) => {
console.log(event);
return {
statusCode: 200,
body: JSON.stringify(event),
};
}
In this example, here is how you would format the input in the AWS Lambda console Test tab.
{ "foo":"Hello", "bar":"World" }
In this example, the Lambda Function expects the input JSON to pass in the foo and bar keys.
export const handler = async (event) => {
console.log(event.foo);
console.log(event.bar);
return (event)
}
Here is a screen shot.

Did you find this article helpful?
If so, consider buying me a coffee over at