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

Updated:   |  Amazon Web Services (AWS) articles

There are various way to POST JSON to one of your NodeJS AWS Lambda Functions.

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 Buy Me A Coffee



Comments


Add a Comment


Please enter a3f89f in the box below so that we can be sure you are a human.