由于配置错误,执行失败:Node JS Lambda中的Lambda代理响应格式错误

时间:2020-04-09 22:00:54

标签: node.js aws-lambda aws-api-gateway aws-serverless

这是Node JS Lambda,我返回状态码200作为响应,当我通过api网关调用lambda函数时,出现502错误,我正在向我的API网关URL发送发帖请求。我正在使用Lambda代理api集成。

      request( options, function ( error, res, body ) {
            if ( error ) {
                console.log( "this is error", error );
                return callback( error );
            } else {
                // console.dir( body );
                const response = {
                    statusCode: 200,
                    body: JSON.stringify({
                      message: 'Your function executed successfully!',
                    //   input: event,
                    }),
                  };
                return callback( null, {
                    response,
                } );
            }
        } );

我正在看到这是日志

(543396a4-952b-451e-8e61-6aeedd2463e9) Endpoint response body before transformations: 
{
    "response": {
    "statusCode": 200,
    "body": "{\"message\":\"Your function executed successfully!\"}"
}
}
 (543396a4-952b-451e-8e61-6aeedd2463e9) Execution failed due to configuration error: 
 Malformed Lambda proxy response
 (543396a4-952b-451e-8e61-6aeedd2463e9) Method completed with status: 502

0 个答案:

没有答案