lambdaとAPI Gatewayで502 InternalServerErrorが出たので修正

lambdaとAPI Gatewayで公開した時こんな感じで書いていたのですが、502でInternalServerErrorがでていました。

"use strict";

module.exports.handle = (event, context, callback) => {
    callback(null, 'finish');
};

調べたところAPI Gatewayを使う場合はcallbackの第二引数にstatusCodeとbodyのキーが必要ということでした。

"use strict";

module.exports.handle = (event, context, callback) => {
    callback(null, { statusCode: 200, body: JSON.stringify({status: 'finish'})});
};