To fix AWS lambda API gateway error "Malformed Lambda proxy response" with JavaScript, we should return a response in the right format.
For instance, our response should have something like
{
"isBase64Encoded": true,
"statusCode": 200,
"headers": { "headerName": "headerValue" },
"body": "..."
}
The properties listed should be in the response JSON.
statusCode
is the HTTP status code.
headers
is an object with the response headers keys and values.
body
is the response body.