1

I am working with a NodeJS Lambda function and when I invoke it I get this as the result:

{
  "body": "{\"message\":\"Hello from Lambda!\"}"
}

It seems as if the response is not being parsed correctly, because according to what I've seen the response should just be the hello world string. This is the code I have with the function.

exports.handler = async (event) => {
  // TODO implement
  const response = {
      body: JSON.stringify({
          message: "Hello from Lambda!",
      }),
  };

  return response;
};

Which is the default code AWS gives you when creating a function. Does anyone know what might be the issue here?

1 Answer 1

1

The return value is exactly what you return. If you just want to return "Hello from Lambda" then your function should be:

exports.handler = async (event) => {
  return "Hello from Lambda!";
};
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you, I'm just starting out with Lambda so thank you very much!
@DanielMedina No problem. Glad it worked out:-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.