Whats wrong with lambda internal server error

Lambda was a great service with great features, and serverless framework is even better, serverless simplified everything you do with AWS or other serverless providers.

Was doing some fun with serverless framework where I am simply trying to output a response from some API to Lambda API gateway, and suddenly I got “Internal server error” with lambda response:

So whats wrong with that? looking in the log it says: “Execution failed due to configuration error: Malformed Lambda proxy response” which means we have some bad format…

Turn out you need to return json format which includes “statusCode”, “header”(no necessary required), “body” as my example below:

  const responseJson = {
    statusCode: 200,
    body: JSON.stringify({
      data: JSON.stringify(response.data)
    }),
  };
  callback(null, responseJson)

Hope this solve your problem with the title.

Published by max

Web developer and Interaction Designer base in Singapore